home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1998 July
/
EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso
/
earcd
/
grafica
/
flashmandel
/
sources
/
flashmandel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-02-02
|
129KB
|
3,896 lines
/*******************************************************************************
**
** Coded by Dino Papararo 01-Feb-1998
**
*******************************************************************************/
#define __USE_SYSBASE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/diskfont.h>
#include <proto/graphics.h>
#include <proto/gadtools.h>
#include <proto/utility.h>
#include <proto/iffparse.h>
#include <proto/icon.h>
#include <proto/asl.h>
#include <exec/execbase.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <graphics/gfxbase.h>
#include <graphics/videocontrol.h>
#include <graphics/scale.h>
#include <iffp/ilbmapp.h>
#include <devices/prtbase.h>
#include <devices/printer.h>
#define __USE_FPU
#ifdef __USE_FPU
#include <m68881.h>
#else
#include <mieeedoub.h>
#endif
#define VERSION "FlashMandel 0.870 "
#define AUTHOR "Dino Papararo"
#define DATE __AMIGADATE__
#define COPYRIGHT "©1997"
#define ADDRESS " Via Manzoni 184\n\n 80123 Napoli\n\n Italia\n\n"
#define EMAIL " E-Mail: DinoP@IName.Com"
#define INIT_DEF_RMIN -2.2
#define INIT_DEF_RMAX +0.8
#define INIT_DEF_IMIN -1.125
#define INIT_DEF_IMAX +1.125
#define INIT_DEF_RMINSTR "-2.2"
#define INIT_DEF_RMAXSTR "+0.8"
#define INIT_DEF_IMINSTR "-1.125"
#define INIT_DEF_IMAXSTR "+1.125"
#define DEF_WIDTH 640
#define DEF_HEIGHT 480
#define DEF_PLANES 4
#define DEF_MONITOR 0x00008004
#define DEF_MONITORSTR "0x00008004"
#define MIN_WIDTH 640
#define MIN_HEIGHT 480
#define MIN_DEPTH 3
#define MAX_DEPTH 8
#define RAW_ESC 0x045
#define VAN_ESC 0x01B
#define TAB 0x042
#define FIXED_POINT (28L) /* Bit di Precisione */
#define MAX_POT (1L << FIXED_POINT) /* 2^FIXED_POINT */
#define MINLIMIT 2
#define BLACK (0)
#define LIGHT_GREY (2)
#define WHITE (1)
#define DARK_GREY (3)
#define POINTS 4
#define PAIRS 5
#define MYSECS (50L << 1L)
#define SHIFTRIGHT FALSE
#define SHIFTLEFT TRUE
#define INITIALZOOM 14
#define ZPW 15
#define ZPH 15
#define ZPXO -8
#define ZPYO -7
#define ZZZPW 16
#define ZZZPH 16
#define ZZZPXO 0
#define ZZZPYO 0
#define MAXCHARS 85
#define ACCEPT (1)
#define RATIO (2)
#define RESET (3)
#define CANCEL (4)
#define KEEP (5)
#define PICTURE_MODE (1)
#define PALETTE_MODE (0)
#define WMASK 0x1
#define FMASK 0x2
#define VMASK 0x4
#define SMASK 0x8
#define BMASK 0x10
#define ZMASK 0x20
#define TMASK 0x40
#define SPREAD_BIT (1L << 16)
#define INTEGER_BIT (1L << 17)
#define TITLE_BIT (1L << 18)
#define LOADPICTURE_MSG 0x1
#define SAVEPICTURE_MSG 0x2
#define DUMP_MSG 0x4
#define REDRAW_MSG 0x8
#define UNDO_MSG 0x10
#define DRAW_MSG 0x20
#define PREVIEW_MSG 0x40
#define NEWDISPLAY_MSG 0x80
#define STOP_MSG 0x100
#define EXIT_MSG 0x200
#define COORDS_MSG 0x400
#define ITER_MSG 0x800
#define ABOUT_MSG 0x1000
#define TITLE_MSG 0x2000
#define TIME_MSG 0x4000
#define PALETTE_MSG 0x8000
#define CYCLERIGHT_MSG 0x10000
#define CYCLELEFT_MSG 0x20000
#define DELAY_MSG 0x40000
#define COLOR_MSG 0x80000
#define LOADPALETTE_MSG 0x100000
#define SAVEPALETTE_MSG 0x200000
#define FONTREQ_MSG 0x400000
#define IDCMP_STANDARD IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE|IDCMP_MENUPICK
#define WFLG_STANDARD WFLG_ACTIVATE|WFLG_BACKDROP|WFLG_NOCAREREFRESH|WFLG_SMART_REFRESH|WFLG_BORDERLESS|WFLG_REPORTMOUSE|WFLG_NEWLOOKMENUS
#define TEXT_ALERT_POS "\x00\x90\x10 FlashMandel message: "
#define MODE_ID_MASK (LACE|HIRES|HAM|EXTRA_HALFBRITE)
#define ID_MAND MAKE_ID('M','A','N','D')
struct MandelChunk { WORD LeftEdge,TopEdge,Width,Height;
long double RMin,RMax,IMin,IMax;
long double RConst,IConst;
ULONG Iterations;
ULONG Special;
};
IMPORT struct ExecBase *SysBase;
TEXT VERSION_STRING [] = "\0$VER: " VERSION DATE "\r\n by " AUTHOR;
TEXT MYFILE [80],MYDIR [220],MYPATH [300],BAR_STRING [80];
BOOL SPREAD = TRUE;
WORD ZOOMLINE [PAIRS << 1] , PRIORITY = 0 , MAX_ITERATIONS = 319;
UWORD MAX_ITERATIONS_PLUS_ONE;
LONG __oslibversion = 39L;
ULONG RETURNVALUE = NULL,MASK = TMASK;
ULONG ELAPSEDTIME = NULL,DELAY = 5L,COLOR_PENS;
long double RMIN=INIT_DEF_RMIN,RMAX=INIT_DEF_RMAX,IMIN=INIT_DEF_IMIN,IMAX=INIT_DEF_IMAX;
long double DEF_RMIN,DEF_RMAX,DEF_IMIN,DEF_IMAX,URMIN,URMAX,UIMIN,UIMAX;
long double FACTOR=0.0,INCREMREAL=0.0,INCREMIMAG=0.0,CRE=0.0,CIM=0.0;
ULONG *PALETTE;
WORD (*FUNCTION) (WORD,long double,long double);
VOID (*V_LINE) (struct RastPort *,const LONG,const LONG,const LONG);
VOID (*H_LINE) (struct RastPort *,const LONG,const LONG,const LONG);
CPTR *VINFO = NULL;
UBYTE *OpenDisplayError = TEXT_ALERT_POS "I need at least 8 colors, sorry." "\x00";
UBYTE *FontError = TEXT_ALERT_POS "Font failed" "\x00";
UBYTE *NoMonitor = TEXT_ALERT_POS "No monitor" "\x00";
UBYTE *NoChips = TEXT_ALERT_POS "No chips" "\x00";
UBYTE *NoMem = TEXT_ALERT_POS "No mem" "\x00";
UBYTE *NoChipMem = TEXT_ALERT_POS "No chipmem" "\x00";
UBYTE *PubNotUnique = TEXT_ALERT_POS "Pub not unique" "\x00";
UBYTE *UnknownMode = TEXT_ALERT_POS "Unknown mode" "\x00";
UBYTE *ScreenTooDeep = TEXT_ALERT_POS "Screen too deep" "\x00";
UBYTE *AttachScreen = TEXT_ALERT_POS "Attach screen failed" "\x00";
UBYTE *ModeNotAvailableError = TEXT_ALERT_POS "Mode not available" "\x00";
UBYTE *UnknownScrError = TEXT_ALERT_POS "Unknown screen error" "\x00";
UBYTE *VisualInfoError = TEXT_ALERT_POS "Visualinfo failed" "\x00";
UBYTE *WindowError = TEXT_ALERT_POS "Openwindow failed" "\x00";
UBYTE *MenuError = TEXT_ALERT_POS "Menu failed" "\x00";
UBYTE *GadgetError = TEXT_ALERT_POS "Gadget error" "\x00";
UBYTE *WindowGadgetError = TEXT_ALERT_POS "Window gadget error" "\x00";
UBYTE *PreviewWindowError = TEXT_ALERT_POS "Preview window failed" "\x00";
UBYTE *CreateDisplayError = TEXT_ALERT_POS "Createdisplay error" "\x00";
UBYTE *DimensionInfoError = TEXT_ALERT_POS "Dimensioninfo error" "\x00";
UBYTE *DisplayInfoError = TEXT_ALERT_POS "Displayinfo error" "\x00";
UBYTE *PaletteRequesterError = TEXT_ALERT_POS "Palette requester error" "\x00";
UBYTE *MakeDisplayError = TEXT_ALERT_POS "Display error" "\x00";
UBYTE *QueryMandPicError = TEXT_ALERT_POS "Not a FlashMandel picture !" "\x00";
UBYTE *LoadMandPicError = TEXT_ALERT_POS "Load picture error" "\x00";
UBYTE *SaveMandPicError = TEXT_ALERT_POS "Save picture error" "\x00";
VOID PutPointer (struct Window *,UWORD *,WORD,WORD,WORD,WORD,UBYTE);
VOID ClipIt (WORD,WORD,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,BOOL);
ULONG ModeFallBack (ULONG,WORD,WORD,WORD);
LONG About (struct Window *);
LONG Choice (struct Window *,TEXT *,TEXT *);
LONG CheckGFX (VOID);
BOOL CheckEHB (ULONG);
UBYTE GetMaxPlanes (ULONG);
ULONG CheckFPU (UWORD);
VOID AdjustRatio (long double *,long double *,long double *,long double *,WORD,WORD,BOOL);
WORD Integer (WORD,long double,long double);
WORD Real (WORD,long double,long double);
VOID ShowTime (struct Window *,TEXT *,ULONG);
ULONG IntegerGad (struct Window *,TEXT *,TEXT *,TEXT *,ULONG);
VOID CloseDisplay (struct ILBMInfo *,CPTR *);
LONG MakeDisplay (struct ILBMInfo *);
VOID VLine_R_EHB (struct RastPort *,const LONG,const LONG,const LONG);
VOID HLine_R_EHB (struct RastPort *,const LONG,const LONG,const LONG);
VOID VLine_S_EHB (struct RastPort *,const LONG,const LONG,const LONG);
VOID HLine_S_EHB (struct RastPort *,const LONG,const LONG,const LONG);
VOID VLine_R (struct RastPort *,const LONG,const LONG,const LONG);
VOID HLine_R (struct RastPort *,const LONG,const LONG,const LONG);
VOID VLine_S (struct RastPort *,const LONG,const LONG,const LONG);
VOID HLine_S (struct RastPort *,const LONG,const LONG,const LONG);
BOOL CheckBox (struct RastPort *,const LONG,const LONG,const LONG,const LONG);
BOOL Rectangle (struct Window *,const LONG,const LONG,const LONG,const LONG);
BOOL NewCoords (struct Window *,const LONG,const LONG,const LONG,const LONG);
BOOL DrawFrame (struct Window *,WORD,WORD,WORD,WORD);
ULONG DrawFractal (struct Window *,const LONG,const LONG,const LONG,const LONG);
BOOL Preview (struct Window *,const LONG,const LONG);
BOOL ShowCoords (struct Window *);
VOID RestoreCoords (VOID);
VOID SaveCoords (VOID);
BOOL FileRequest (struct Window *,TEXT *,BOOL,BOOL);
BOOL FontRequest (struct Window *);
BOOL SMRequest (struct ILBMInfo *);
VOID SetMenuStart (struct Window *);
VOID SetMenuStop (struct Window *);
ULONG ProcessMenu (struct Window *,UWORD);
VOID ProcessMouse (struct Window *,WORD,WORD);
ULONG HandleEvents (struct ILBMInfo *);
LONG WinDump (struct Window *);
ULONG Fail (UBYTE *,ULONG);
BOOL PasteWin (struct BitMap *,struct Window *,WORD,WORD);
LONG main (ULONG,UBYTE **);
struct Screen *OpenIdScreen (struct ILBMInfo *,WORD,WORD,WORD,ULONG);
struct Window *OpenDisplay (struct ILBMInfo *,WORD,WORD,WORD,ULONG);
struct BitMap *CopyBitMap (struct Window *,WORD,WORD,WORD,WORD);
struct Border MYBORDER = {0,0,0,0,COMPLEMENT,PAIRS,ZOOMLINE,0};
struct TextAttr MYFONTSTRUCT = {"topaz.font",8,FS_NORMAL,FPF_ROMFONT};
struct NewGadget TEXTGAD = {0,0,0,0,0,&MYFONTSTRUCT,0,0,0,0};
struct NewGadget BUTTONGAD = {0,0,0,0,0,&MYFONTSTRUCT,0,0,0,0};
struct NewGadget CHECKBOXGAD = {0,0,0,0,0,&MYFONTSTRUCT,0,0,0,0};
struct BitScaleArgs BSA = {0,0,0,0,0,0,0,0,0,0,0,0,NULL,NULL,NULL,0,0,NULL,NULL};
struct Chunk COPYRIGHT_CHUNK = {NULL,ID_ILBM,ID_Copyright,IFFSIZE_UNKNOWN,"\n\n" VERSION COPYRIGHT " by " AUTHOR "\n\n"};
struct Chunk SPECIAL_CHUNK = {NULL,ID_ILBM,ID_MAND,sizeof (struct MandelChunk),NULL};
UWORD PENS [] = {BLACK,DARK_GREY,WHITE,WHITE,DARK_GREY,LIGHT_GREY,DARK_GREY,LIGHT_GREY,DARK_GREY,WHITE,LIGHT_GREY,DARK_GREY,(UWORD) ~0};
/*
01 0 DETAILPEN SFONDO
02 1 BLOCKPEN TESTO
03 1 TEXTPEN TESTO EVIDENZIATO
04 2 SHINEPEN BORDI CHIARI
05 1 SHADOWPEN BORDI SCURI
06 3 FILLPEN BARRA TITOLO FINESTRE ATTIVE
07 1 FILLTEXTPEN TITOLO FINESTRE ATTIVE
08 0 BACKGROUNDPEN
09 2 HIGHLIGHTTEXTPEN
10 1 BARDETAILPEN TESTO NEI MENU
11 2 BARBLOCKPEN SFONDO NEI MENU
12 1 BARTRIMPEN
*/
ULONG COLORS_32_ECS [] = {32L << 16L,
0x00000000,0x00000000,0x00000000,
0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,
0x66666666,0x66666666,0x66666666,
0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
0xBBBBBBBB,0xBBBBBBBB,0xBBBBBBBB,
0x77777777,0x77777777,0x77777777,
0x33333333,0x33333333,0x33333333,
0x33333333,0x33333333,0x00000000,
0x77777777,0x77777777,0x00000000,
0xBBBBBBBB,0xBBBBBBBB,0x00000000,
0xFFFFFFFF,0xFFFFFFFF,0x00000000,
0x00000000,0xFFFFFFFF,0x00000000,
0x00000000,0xBBBBBBBB,0x00000000,
0x00000000,0x77777777,0x00000000,
0x00000000,0x33333333,0x00000000,
0x33333333,0x00000000,0x33333333,
0x77777777,0x00000000,0x77777777,
0xBBBBBBBB,0x00000000,0xBBBBBBBB,
0xFFFFFFFF,0x00000000,0xFFFFFFFF,
0xFFFFFFFF,0x00000000,0x00000000,
0xBBBBBBBB,0x00000000,0x00000000,
0x77777777,0x00000000,0x00000000,
0x33333333,0x00000000,0x00000000,
0x00000000,0x33333333,0x33333333,
0x00000000,0x77777777,0x77777777,
0x00000000,0xBBBBBBBB,0xBBBBBBBB,
0x00000000,0xFFFFFFFF,0xFFFFFFFF,
0x00000000,0x00000000,0xFFFFFFFF,
0x00000000,0x00000000,0xBBBBBBBB,
0x00000000,0x00000000,0x77777777,
0x00000000,0x00000000,0x33333333,
NULL};
ULONG COLORS_32_AGA [] = {256L << 16L,
0x00000000,0x00000000,0x00000000, 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA, 0x66666666,0x66666666,0x66666666,
0x9f9f9f9f,0x9f9f9f9f,0x9f9f9f9f, 0xafafafaf,0xafafafaf,0xafafafaf, 0xbfbfbfbf,0xbfbfbfbf,0xbfbfbfbf, 0xcfcfcfcf,0xcfcfcfcf,0xcfcfcfcf,
0xdfdfdfdf,0xdfdfdfdf,0xdfdfdfdf, 0xefefefef,0xefefefef,0xefefefef, 0xdfdfdfdf,0xefefefef,0xffffffff, 0xcfcfcfcf,0xdfdfdfdf,0xefefefef,
0xbfbfbfbf,0xcfcfcfcf,0xdfdfdfdf, 0xafafafaf,0xbfbfbfbf,0xcfcfcfcf, 0x9f9f9f9f,0xafafafaf,0xbfbfbfbf, 0x8f8f8f8f,0x9f9f9f9f,0xafafafaf,
0x7f7f7f7f,0x8f8f8f8f,0x9f9f9f9f, 0x6f6f6f6f,0x7f7f7f7f,0x8f8f8f8f, 0x5f5f5f5f,0x6f6f6f6f,0x7f7f7f7f, 0x4f4f4f4f,0x5f5f5f5f,0x6f6f6f6f,
0x3f3f3f3f,0x4f4f4f4f,0x5f5f5f5f, 0x2f2f2f2f,0x3f3f3f3f,0x4f4f4f4f, 0x1f1f1f1f,0x2f2f2f2f,0x3f3f3f3f, 0x0f0f0f0f,0x1f1f1f1f,0x2f2f2f2f,
0x00000000,0x0f0f0f0f,0x1f1f1f1f, 0x1f1f1f1f,0x0f0f0f0f,0x1f1f1f1f, 0x2f2f2f2f,0x1f1f1f1f,0x2f2f2f2f, 0x3f3f3f3f,0x2f2f2f2f,0x3f3f3f3f,
0x4f4f4f4f,0x3f3f3f3f,0x4f4f4f4f, 0x5f5f5f5f,0x4f4f4f4f,0x5f5f5f5f, 0x6f6f6f6f,0x5f5f5f5f,0x6f6f6f6f, 0x7f7f7f7f,0x6f6f6f6f,0x7f7f7f7f,
0x8f8f8f8f,0x7f7f7f7f,0x8f8f8f8f, 0x9f9f9f9f,0x8f8f8f8f,0x9f9f9f9f, 0xafafafaf,0x9f9f9f9f,0xafafafaf, 0xbfbfbfbf,0xafafafaf,0xbfbfbfbf,
0xcfcfcfcf,0xbfbfbfbf,0xcfcfcfcf, 0xdfdfdfdf,0xcfcfcfcf,0xdfdfdfdf, 0xefefefef,0xdfdfdfdf,0xefefefef, 0xffffffff,0xefefefef,0xffffffff,
0xefefefef,0xffffffff,0xefefefef, 0xdfdfdfdf,0xefefefef,0xdfdfdfdf, 0xcfcfcfcf,0xdfdfdfdf,0xcfcfcfcf, 0xbfbfbfbf,0xcfcfcfcf,0xbfbfbfbf,
0xafafafaf,0xbfbfbfbf,0xafafafaf, 0x9f9f9f9f,0xafafafaf,0x9f9f9f9f, 0x8f8f8f8f,0x9f9f9f9f,0x8f8f8f8f, 0x7f7f7f7f,0x8f8f8f8f,0x7f7f7f7f,
0x6f6f6f6f,0x7f7f7f7f,0x6f6f6f6f, 0x5f5f5f5f,0x6f6f6f6f,0x5f5f5f5f, 0x4f4f4f4f,0x5f5f5f5f,0x4f4f4f4f, 0x3f3f3f3f,0x4f4f4f4f,0x3f3f3f3f,
0x2f2f2f2f,0x3f3f3f3f,0x2f2f2f2f, 0x1f1f1f1f,0x2f2f2f2f,0x1f1f1f1f, 0x0f0f0f0f,0x1f1f1f1f,0x0f0f0f0f, 0x0f0f0f0f,0x1f1f1f1f,0x1f1f1f1f,
0x1f1f1f1f,0x2f2f2f2f,0x2f2f2f2f, 0x2f2f2f2f,0x3f3f3f3f,0x3f3f3f3f, 0x3f3f3f3f,0x4f4f4f4f,0x4f4f4f4f, 0x4f4f4f4f,0x5f5f5f5f,0x5f5f5f5f,
0x5f5f5f5f,0x6f6f6f6f,0x6f6f6f6f, 0x6f6f6f6f,0x7f7f7f7f,0x7f7f7f7f, 0x7f7f7f7f,0x8f8f8f8f,0x8f8f8f8f, 0x8f8f8f8f,0x9f9f9f9f,0x9f9f9f9f,
0x9f9f9f9f,0xafafafaf,0xafafafaf, 0xafafafaf,0xbfbfbfbf,0xbfbfbfbf, 0xbfbfbfbf,0xcfcfcfcf,0xcfcfcfcf, 0xcfcfcfcf,0xdfdfdfdf,0xdfdfdfdf,
0xdfdfdfdf,0xefefefef,0xefefefef, 0xefefefef,0xffffffff,0xffffffff, 0xffffffff,0xefefefef,0xefefefef, 0xefefefef,0xdfdfdfdf,0xdfdfdfdf,
0xdfdfdfdf,0xcfcfcfcf,0xcfcfcfcf, 0xcfcfcfcf,0xbfbfbfbf,0xbfbfbfbf, 0xbfbfbfbf,0xafafafaf,0xafafafaf, 0xafafafaf,0x9f9f9f9f,0x9f9f9f9f,
0x9f9f9f9f,0x8f8f8f8f,0x8f8f8f8f, 0x8f8f8f8f,0x7f7f7f7f,0x7f7f7f7f, 0x7f7f7f7f,0x6f6f6f6f,0x6f6f6f6f, 0x6f6f6f6f,0x5f5f5f5f,0x5f5f5f5f,
0x5f5f5f5f,0x4f4f4f4f,0x4f4f4f4f, 0x4f4f4f4f,0x3f3f3f3f,0x3f3f3f3f, 0x3f3f3f3f,0x2f2f2f2f,0x2f2f2f2f, 0x2f2f2f2f,0x1f1f1f1f,0x1f1f1f1f,
0x1f1f1f1f,0x0f0f0f0f,0x0f0f0f0f, 0x1f1f1f1f,0x1f1f1f1f,0x0f0f0f0f, 0x2f2f2f2f,0x2f2f2f2f,0x1f1f1f1f, 0x3f3f3f3f,0x3f3f3f3f,0x2f2f2f2f,
0x4f4f4f4f,0x4f4f4f4f,0x3f3f3f3f, 0x5f5f5f5f,0x5f5f5f5f,0x4f4f4f4f, 0x6f6f6f6f,0x6f6f6f6f,0x5f5f5f5f, 0x7f7f7f7f,0x7f7f7f7f,0x6f6f6f6f,
0x8f8f8f8f,0x8f8f8f8f,0x7f7f7f7f, 0x9f9f9f9f,0x9f9f9f9f,0x8f8f8f8f, 0xafafafaf,0xafafafaf,0x9f9f9f9f, 0xbfbfbfbf,0xbfbfbfbf,0xafafafaf,
0xcfcfcfcf,0xcfcfcfcf,0xbfbfbfbf, 0xdfdfdfdf,0xdfdfdfdf,0xcfcfcfcf, 0xefefefef,0xefefefef,0xdfdfdfdf, 0xffffffff,0xffffffff,0xefefefef,
0xefefefef,0xefefefef,0xffffffff, 0xdfdfdfdf,0xdfdfdfdf,0xefefefef, 0xcfcfcfcf,0xcfcfcfcf,0xdfdfdfdf, 0xbfbfbfbf,0xbfbfbfbf,0xcfcfcfcf,
0xafafafaf,0xafafafaf,0xbfbfbfbf, 0x9f9f9f9f,0x9f9f9f9f,0xafafafaf, 0x8f8f8f8f,0x8f8f8f8f,0x9f9f9f9f, 0x7f7f7f7f,0x7f7f7f7f,0x8f8f8f8f,
0x6f6f6f6f,0x6f6f6f6f,0x7f7f7f7f, 0x5f5f5f5f,0x5f5f5f5f,0x6f6f6f6f, 0x4f4f4f4f,0x4f4f4f4f,0x5f5f5f5f, 0x3f3f3f3f,0x3f3f3f3f,0x4f4f4f4f,
0x2f2f2f2f,0x2f2f2f2f,0x3f3f3f3f, 0x1f1f1f1f,0x1f1f1f1f,0x2f2f2f2f, 0x0f0f0f0f,0x0f0f0f0f,0x1f1f1f1f, 0x0f0f0f0f,0x0f0f0f0f,0x00000000,
0x1f1f1f1f,0x1f1f1f1f,0x00000000, 0x2f2f2f2f,0x2f2f2f2f,0x00000000, 0x3f3f3f3f,0x3f3f3f3f,0x00000000, 0x4f4f4f4f,0x4f4f4f4f,0x00000000,
0x5f5f5f5f,0x5f5f5f5f,0x00000000, 0x6f6f6f6f,0x6f6f6f6f,0x00000000, 0x7f7f7f7f,0x7f7f7f7f,0x00000000, 0x8f8f8f8f,0x8f8f8f8f,0x00000000,
0x9f9f9f9f,0x9f9f9f9f,0x00000000, 0xafafafaf,0xafafafaf,0x00000000, 0xbfbfbfbf,0xbfbfbfbf,0x00000000, 0xcfcfcfcf,0xcfcfcfcf,0x00000000,
0xdfdfdfdf,0xdfdfdfdf,0x00000000, 0xefefefef,0xefefefef,0x00000000, 0xffffffff,0xffffffff,0x00000000, 0xefefefef,0xffffffff,0x00000000,
0xdfdfdfdf,0xffffffff,0x00000000, 0xcfcfcfcf,0xffffffff,0x00000000, 0xbfbfbfbf,0xffffffff,0x00000000, 0xafafafaf,0xffffffff,0x00000000,
0x9f9f9f9f,0xffffffff,0x00000000, 0x8f8f8f8f,0xffffffff,0x00000000, 0x7f7f7f7f,0xffffffff,0x00000000, 0x6f6f6f6f,0xffffffff,0x00000000,
0x5f5f5f5f,0xffffffff,0x00000000, 0x4f4f4f4f,0xffffffff,0x00000000, 0x3f3f3f3f,0xffffffff,0x00000000, 0x2f2f2f2f,0xffffffff,0x00000000,
0x1f1f1f1f,0xffffffff,0x00000000, 0x0f0f0f0f,0xffffffff,0x00000000, 0x00000000,0xffffffff,0x00000000, 0x00000000,0xefefefef,0x00000000,
0x00000000,0xdfdfdfdf,0x00000000, 0x00000000,0xcfcfcfcf,0x00000000, 0x00000000,0xbfbfbfbf,0x00000000, 0x00000000,0xafafafaf,0x00000000,
0x00000000,0x9f9f9f9f,0x00000000, 0x00000000,0x8f8f8f8f,0x00000000, 0x00000000,0x7f7f7f7f,0x00000000, 0x00000000,0x6f6f6f6f,0x00000000,
0x00000000,0x5f5f5f5f,0x00000000, 0x00000000,0x4f4f4f4f,0x00000000, 0x00000000,0x3f3f3f3f,0x00000000, 0x00000000,0x2f2f2f2f,0x00000000,
0x00000000,0x1f1f1f1f,0x00000000, 0x00000000,0x0f0f0f0f,0x00000000, 0x0f0f0f0f,0x00000000,0x0f0f0f0f, 0x1f1f1f1f,0x00000000,0x1f1f1f1f,
0x2f2f2f2f,0x00000000,0x2f2f2f2f, 0x3f3f3f3f,0x00000000,0x3f3f3f3f, 0x4f4f4f4f,0x00000000,0x4f4f4f4f, 0x5f5f5f5f,0x00000000,0x5f5f5f5f,
0x6f6f6f6f,0x00000000,0x6f6f6f6f, 0x7f7f7f7f,0x00000000,0x7f7f7f7f, 0x8f8f8f8f,0x00000000,0x8f8f8f8f, 0x9f9f9f9f,0x00000000,0x9f9f9f9f,
0xafafafaf,0x00000000,0xafafafaf, 0xbfbfbfbf,0x00000000,0xbfbfbfbf, 0xcfcfcfcf,0x00000000,0xcfcfcfcf, 0xdfdfdfdf,0x00000000,0xdfdfdfdf,
0xefefefef,0x00000000,0xefefefef, 0xffffffff,0x00000000,0xffffffff, 0xffffffff,0x00000000,0xefefefef, 0xffffffff,0x00000000,0xdfdfdfdf,
0xffffffff,0x00000000,0xcfcfcfcf, 0xffffffff,0x00000000,0xbfbfbfbf, 0xffffffff,0x00000000,0xafafafaf, 0xffffffff,0x00000000,0x9f9f9f9f,
0xffffffff,0x00000000,0x8f8f8f8f, 0xffffffff,0x00000000,0x7f7f7f7f, 0xffffffff,0x00000000,0x6f6f6f6f, 0xffffffff,0x00000000,0x5f5f5f5f,
0xffffffff,0x00000000,0x4f4f4f4f, 0xffffffff,0x00000000,0x3f3f3f3f, 0xffffffff,0x00000000,0x2f2f2f2f, 0xffffffff,0x00000000,0x1f1f1f1f,
0xffffffff,0x00000000,0x0f0f0f0f, 0xffffffff,0x00000000,0x00000000, 0xefefefef,0x00000000,0x00000000, 0xdfdfdfdf,0x00000000,0x00000000,
0xcfcfcfcf,0x00000000,0x00000000, 0xbfbfbfbf,0x00000000,0x00000000, 0xafafafaf,0x00000000,0x00000000, 0x9f9f9f9f,0x00000000,0x00000000,
0x8f8f8f8f,0x00000000,0x00000000, 0x7f7f7f7f,0x00000000,0x00000000, 0x6f6f6f6f,0x00000000,0x00000000, 0x5f5f5f5f,0x00000000,0x00000000,
0x4f4f4f4f,0x00000000,0x00000000, 0x3f3f3f3f,0x00000000,0x00000000, 0x2f2f2f2f,0x00000000,0x00000000, 0x1f1f1f1f,0x00000000,0x00000000,
0x0f0f0f0f,0x00000000,0x00000000, 0x00000000,0x0f0f0f0f,0x0f0f0f0f, 0x00000000,0x1f1f1f1f,0x1f1f1f1f, 0x00000000,0x2f2f2f2f,0x2f2f2f2f,
0x00000000,0x3f3f3f3f,0x3f3f3f3f, 0x00000000,0x4f4f4f4f,0x4f4f4f4f, 0x00000000,0x5f5f5f5f,0x5f5f5f5f, 0x00000000,0x6f6f6f6f,0x6f6f6f6f,
0x00000000,0x7f7f7f7f,0x7f7f7f7f, 0x00000000,0x8f8f8f8f,0x8f8f8f8f, 0x00000000,0x9f9f9f9f,0x9f9f9f9f, 0x00000000,0xafafafaf,0xafafafaf,
0x00000000,0xbfbfbfbf,0xbfbfbfbf, 0x00000000,0xcfcfcfcf,0xcfcfcfcf, 0x00000000,0xdfdfdfdf,0xdfdfdfdf, 0x00000000,0xefefefef,0xefefefef,
0x00000000,0xffffffff,0xffffffff, 0x00000000,0xefefefef,0xffffffff, 0x00000000,0xdfdfdfdf,0xffffffff, 0x00000000,0xcfcfcfcf,0xffffffff,
0x00000000,0xbfbfbfbf,0xffffffff, 0x00000000,0xafafafaf,0xffffffff, 0x00000000,0x9f9f9f9f,0xffffffff, 0x00000000,0x8f8f8f8f,0xffffffff,
0x00000000,0x7f7f7f7f,0xffffffff, 0x00000000,0x6f6f6f6f,0xffffffff, 0x00000000,0x5f5f5f5f,0xffffffff, 0x00000000,0x4f4f4f4f,0xffffffff,
0x00000000,0x3f3f3f3f,0xffffffff, 0x00000000,0x2f2f2f2f,0xffffffff, 0x00000000,0x1f1f1f1f,0xffffffff, 0x00000000,0x0f0f0f0f,0xffffffff,
0x00000000,0x00000000,0xffffffff, 0x00000000,0x00000000,0xefefefef, 0x00000000,0x00000000,0xdfdfdfdf, 0x00000000,0x00000000,0xcfcfcfcf,
0x00000000,0x00000000,0xbfbfbfbf, 0x00000000,0x00000000,0xafafafaf, 0x00000000,0x00000000,0x9f9f9f9f, 0x00000000,0x00000000,0x8f8f8f8f,
0x00000000,0x00000000,0x7f7f7f7f, 0x00000000,0x00000000,0x6f6f6f6f, 0x00000000,0x00000000,0x5f5f5f5f, 0x00000000,0x00000000,0x4f4f4f4f,
0x00000000,0x00000000,0x3f3f3f3f, 0x00000000,0x00000000,0x2f2f2f2f, 0x00000000,0x00000000,0x1f1f1f1f, 0x00000000,0x00000000,0x0f0f0f0f,
NULL};
UWORD chip ZZZPointer[] = {0x0000,0x0000,0x0400,0x07C0,0x0000,0x07C0,0x0100,0x0380,
0x0000,0x07E0,0x07C0,0x1FF8,0x1FF0,0x3FEC,0x3FF8,0x7FDE,
0x3FF8,0x7FBE,0x7FFC,0xFF7F,0x7EFC,0xFFFF,0x7FFC,0xFFFF,
0x3FF8,0x7FFE,0x3FF8,0x7FFE,0x1FF0,0x3FFC,0x07C0,0x1FF8,
0x0000,0x07E0,0x0000,0x0000};
UWORD chip ZoomPointer[] = {0x0000,0x0000,0x0100,0x0000,0x0100,0x0000,0x0000,0x0100,
0x0000,0x0100,0x0100,0x0100,0x0100,0x0100,0x0000,0x0000,
0xCC66,0x3C78,0x0000,0x0000,0x0100,0x0100,0x0100,0x0100,
0x0000,0x0100,0x0000,0x0100,0x0100,0x0000,0x0100,0x0000,
0x0000,0x0000};
struct NewMenu ProgMenu[] = { NM_TITLE,"Project",0,0,0,0,
NM_ITEM,"About...","A",NM_ITEMDISABLED,0,0,
NM_ITEM,NM_BARLABEL,0,0,0,0,
NM_ITEM,"Load picture...","L",NM_ITEMDISABLED,0,0,
NM_ITEM,"Save picture...","S",NM_ITEMDISABLED,0,0,
NM_ITEM,"Load palette...","K",NM_ITEMDISABLED,0,0,
NM_ITEM,"Save palette...","J",NM_ITEMDISABLED,0,0,
NM_ITEM,NM_BARLABEL,0,0,0,0,
NM_ITEM,"Print...","D",NM_ITEMDISABLED,0,0,
NM_ITEM,NM_BARLABEL,0,0,0,0,
NM_ITEM,"Quit...","Q",NM_ITEMDISABLED,0,0,
/***************************************************************************************/
NM_TITLE,"Options",0,0,0,0,
NM_ITEM,"Title",0,NM_ITEMDISABLED,0,0,
NM_SUB,"On/Off","O",CHECKIT|CHECKED,0,0,
NM_SUB,NM_BARLABEL,0,0,0,0,
NM_SUB,"Last time","T",0,0,0,
NM_ITEM,"Limits...","C",NM_ITEMDISABLED,0,0,
NM_ITEM,"Iterations",0,NM_ITEMDISABLED,0,0,
NM_SUB,"64",0,CHECKIT,~(1<<0),0,
NM_SUB,"128",0,CHECKIT,~(1<<1),0,
NM_SUB,"192",0,CHECKIT,~(1<<2),0,
NM_SUB,"256",0,CHECKIT,~(1<<3),0,
NM_SUB,"320",0,CHECKIT|CHECKED,~(1<<4),0,
NM_SUB,"384",0,CHECKIT,~(1<<5),0,
NM_SUB,"448",0,CHECKIT,~(1<<6),0,
NM_SUB,"512",0,CHECKIT,~(1<<7),0,
NM_SUB,"1024",0,CHECKIT,~(1<<8),0,
NM_SUB,NM_BARLABEL,0,0,0,0,
NM_SUB,"Custom...","I",CHECKIT,~(1<<10),0,
NM_ITEM,"Priority",0,0,0,0,
NM_SUB,"-5","%",CHECKIT,~(1<<0),0,
NM_SUB,"-4","$",CHECKIT,~(1<<1),0,
NM_SUB,"-3","£",CHECKIT,~(1<<2),0,
NM_SUB,"-2","\"",CHECKIT,~(1<<3),0,
NM_SUB,"-1","!",CHECKIT,~(1<<4),0,
NM_SUB,NM_BARLABEL,0,0,0,0,
NM_SUB," 0","0",CHECKIT|CHECKED,~(1<<6),0,
NM_SUB,NM_BARLABEL,0,0,0,0,
NM_SUB,"+1","1",CHECKIT,~(1<<8),0,
NM_SUB,"+2","2",CHECKIT,~(1<<9),0,
NM_SUB,"+3","3",CHECKIT,~(1<<10),0,
NM_SUB,"+4","4",CHECKIT,~(1<<11),0,
NM_SUB,"+5","5",CHECKIT,~(1<<12),0,
NM_ITEM,"Color mapping",0,0,0,0,
NM_SUB,"Repeated",0,CHECKIT,~(1<<0),0,
NM_SUB,"Spread",0,CHECKIT|CHECKED,~(1<<1),0,
NM_ITEM,"Precision",0,0,0,0,
NM_SUB,"Integer",0,CHECKIT|CHECKED,~(1<<0),0,
NM_SUB,"Real",0,CHECKIT,~(1<<1),0,
/***************************************************************************************/
NM_TITLE,"Calculate",0,0,0,0,
NM_ITEM,"PreView","W",NM_ITEMDISABLED,0,0,
NM_ITEM,NM_BARLABEL,0,0,0,0,
NM_ITEM,"ReCalculate","R",NM_ITEMDISABLED,0,0,
NM_ITEM,NM_BARLABEL,0,0,0,0,
NM_ITEM,"Undo","U",NM_ITEMDISABLED,0,0,
NM_ITEM,NM_BARLABEL,0,0,0,0,
NM_ITEM,"Zoom","Z",NM_ITEMDISABLED,0,0,
NM_ITEM,"Stop","X",0,0,0,
/***************************************************************************************/
NM_TITLE,"Video",0,0,0,0,
NM_ITEM,"Cycle",0,NM_ITEMDISABLED,0,0,
NM_SUB,"Forward",">",0,0,0,
NM_SUB,"Backward","<",0,0,0,
NM_SUB,NM_BARLABEL,0,0,0,0,
NM_SUB,"Delay...","-",0,0,0,
NM_ITEM,NM_BARLABEL,0,0,0,0,
NM_ITEM,"Palette...","P",NM_ITEMDISABLED,0,0,
NM_ITEM,NM_BARLABEL,0,0,0,0,
NM_ITEM,"Screen mode...","V",NM_ITEMDISABLED,0,0,
NM_ITEM,NM_BARLABEL,0,0,0,0,
NM_ITEM,"Font settings...","F",NM_ITEMDISABLED,0,0,
NM_END,0,0,0,0,0 };
struct Menu *MAINMENU = NULL;
struct BitMap *MYBITMAP = NULL;
struct Task *THISTASK = NULL;
struct TextFont *NEWFONT = NULL;
struct ILBMInfo MYILBM;
struct MandelChunk MANDChunk;
struct MandelChunk *MANDChunkTmp = NULL;
LONG IlbmProps [] = { ID_ILBM, ID_BMHD, ID_ILBM, ID_CMAP, ID_ILBM, ID_CAMG, ID_ILBM, ID_MAND, TAG_END };
LONG IlbmCollects [] = { TAG_END };
LONG IlbmStops [] = { ID_ILBM, ID_BODY, TAG_END };
IMPORT BOOL ModifyPalette (struct Window *,WORD,WORD,WORD,WORD,ULONG *);
IMPORT BOOL Cycle (struct Window *,ULONG,BOOL);
IMPORT WORD __asm MandInt (register __d0 WORD,register __d1 LONG,register __d2 LONG);
IMPORT LONG QueryMandPic (struct ILBMInfo *,struct MandelChunk **,UBYTE *);
IMPORT LONG LoadMandPic (struct ILBMInfo *,UBYTE *);
IMPORT LONG SaveMandPic (struct ILBMInfo *,struct Chunk *,struct Chunk *,UBYTE *);
IMPORT LONG LoadPalette (struct ILBMInfo *,UBYTE *);
IMPORT LONG SavePalette (struct ILBMInfo *,struct Chunk *,UBYTE *);
VOID PutPointer (struct Window *Win,UWORD *PointerImage,WORD Width,WORD Height,WORD XOrigin,WORD YOrigin,UBYTE Type)
{
switch (Type)
{
case 0: SetWindowPointer (Win,TAG_END);
break;
case 1: SetWindowPointer (Win,WA_BusyPointer,TRUE,WA_PointerDelay,TRUE,TAG_END);
break;
default: SetPointer (Win,PointerImage,Height,Width,XOrigin,YOrigin);
}
}
UBYTE GetMaxPlanes (ULONG ModeID)
{
DisplayInfoHandle DisplayHandle;
struct DimensionInfo DimensionInfo;
UBYTE Planes = 0;
DisplayHandle = FindDisplayInfo (ModeID);
if (GetDisplayInfoData (DisplayHandle,(UBYTE *) &DimensionInfo,sizeof (struct DimensionInfo),DTAG_DIMS,ModeID))
{
Planes = DimensionInfo.MaxDepth;
}
else Fail (DimensionInfoError,20L);
return Planes;
}
LONG CheckGFX (VOID)
{
BOOL AGA = FALSE,RTG = FALSE;
ULONG ModeID = INVALID_ID;
if (GetMaxPlanes (LORES_KEY) == MAX_DEPTH) AGA = TRUE;
while (((ModeID = NextDisplayInfo (ModeID)) != INVALID_ID) && RTG == FALSE)
{
if (GetMaxPlanes (ModeID) > MAX_DEPTH) RTG = TRUE;
}
if (RTG && AGA) return 3L;
if (RTG) return 2L;
if (AGA) return 1L;
return NULL;
}
BOOL CheckEHB (ULONG ModeID)
{
DisplayInfoHandle DisplayHandle;
struct DisplayInfo DisplayInfo;
BOOL IsEHB = FALSE;
DisplayHandle = FindDisplayInfo (ModeID);
if (GetDisplayInfoData (DisplayHandle,(UBYTE *) &DisplayInfo,sizeof (struct DisplayInfo),DTAG_DISP,ModeID))
{
if (DisplayInfo.PropertyFlags & DIPF_IS_EXTRAHALFBRITE) IsEHB = TRUE;
}
else Fail (DisplayInfoError,20L);
return IsEHB;
}
ULONG CheckFPU (UWORD CpuFlags)
{
if (AFF_68060 & CpuFlags) return 68884L;
if (AFF_FPU40 & CpuFlags) return 68883L;
if (AFF_68882 & CpuFlags) return 68882L;
if (AFF_68881 & CpuFlags) return 68881L;
return NULL;
}
VOID CloseDisplay (struct ILBMInfo *Ilbm,CPTR *VInfo)
{
if (WMASK & MASK)
{
ClearMenuStrip (Ilbm->win);
PutPointer (Ilbm->win,0,0,0,0,0,0);
CloseWindow (Ilbm->win);
Ilbm->win = NULL;
Ilbm->wrp = NULL;
MASK ^= WMASK;
}
if (VMASK & MASK)
{
FreeVisualInfo (VInfo);
MASK ^= VMASK;
}
if (SMASK & MASK)
{
CloseScreen (Ilbm->scr);
Ilbm->scr = NULL;
Ilbm->vp = NULL;
Ilbm->srp = NULL;
MASK ^= SMASK;
}
if (FMASK & MASK)
{
CloseFont (NEWFONT);
MASK ^= FMASK;
}
}
struct Window *OpenDisplay (struct ILBMInfo *Ilbm,WORD Width,WORD Height,WORD Depth,ULONG ModeID)
{
struct Screen *Scr;
struct Window *Win = NULL;
if (Scr = OpenIdScreen (Ilbm,Width,Height,Depth,ModeID))
{
Win = OpenWindowTags (NULL,
WA_Left,Scr->LeftEdge,
WA_Top,Scr->TopEdge,
WA_Width,Scr->Width,
WA_Height,Scr->Height,
WA_ScreenTitle,VERSION,
WA_CustomScreen,Scr,
WA_MouseQueue,1L,
WA_IDCMP,IDCMP_STANDARD,
WA_Flags,WFLG_STANDARD,
TAG_END);
if (! Win)
{
if (Scr) CloseScreen (Scr);
return NULL;
}
Ilbm->scr = Scr;
Ilbm->win = Win;
Ilbm->vp = &(Scr->ViewPort);
Ilbm->srp = &(Scr->RastPort);
Ilbm->wrp = Win->RPort;
Ilbm->Bmhd.w = Ilbm->win->Width;
Ilbm->Bmhd.h = Ilbm->win->Height;
Ilbm->Bmhd.nPlanes = Ilbm->wrp->BitMap->Depth;
}
return (Win);
}
struct Screen *OpenIdScreen (struct ILBMInfo *Ilbm,WORD Width,WORD Height,WORD Depth,ULONG ModeID)
{
struct Rectangle Spos,DClip,TxtO,StdO,MaxO,UClip;
struct Rectangle *UClipp;
struct Screen *Scr;
LONG ErrorCode = NULL,TryNew;
ULONG BitMapTag,PassedTags;
if (! Ilbm) return (NULL);
TryNew = ((QueryOverscan (ModeID,&TxtO,OSCAN_TEXT)) && (QueryOverscan (ModeID,&StdO,OSCAN_STANDARD)) && (QueryOverscan (ModeID,&MaxO,OSCAN_MAX)));
if (TryNew)
{
if (Ilbm->Video) Ilbm->ucliptype = OSCAN_VIDEO;
if ((Ilbm->ucliptype) && (QueryOverscan (ModeID,&UClip,Ilbm->ucliptype))) UClipp = &UClip;
else UClipp = NULL;
ClipIt (Width,Height,&Spos,&DClip,&TxtO,&StdO,&MaxO,UClipp,Ilbm->IFFPFlags & IFFPF_NOCENTER ? TRUE : FALSE);
BitMapTag = ((Ilbm->brbitmap) && (Ilbm->stype & CUSTOMBITMAP)) ? SA_BitMap : TAG_IGNORE;
PassedTags = Ilbm->stags ? TAG_MORE : TAG_IGNORE;
Scr = OpenScreenTags (NULL,
SA_DisplayID, ModeID,
SA_Type, Ilbm->stype,
SA_Top, Spos.MinY,
SA_Left, Spos.MinX,
SA_Width, Width,
SA_Height, Height,
SA_Depth, Depth,
SA_DClip, &DClip,
SA_AutoScroll, Ilbm->Autoscroll,
SA_Colors32, PALETTE,
SA_Pens, PENS,
SA_Interleaved, TRUE,
SA_Font, &MYFONTSTRUCT,
SA_Title, VERSION,
SA_ErrorCode, &ErrorCode,
SA_ShowTitle, Ilbm->TBState,
BitMapTag, Ilbm->brbitmap,
PassedTags, Ilbm->stags,
TAG_END);
if (! Scr)
{
switch (ErrorCode)
{
case OSERR_NOMONITOR : Fail (NoMonitor,20L);
break;
case OSERR_NOCHIPS : Fail (NoChips,20L);
break;
case OSERR_NOMEM : Fail (NoMem,20L);
break;
case OSERR_NOCHIPMEM : Fail (NoChipMem,20L);
break;
case OSERR_PUBNOTUNIQUE: Fail (PubNotUnique,20L);
break;
case OSERR_UNKNOWNMODE : Fail (UnknownMode,20L);
break;
case OSERR_TOODEEP : Fail (ScreenTooDeep,20L);
break;
case OSERR_ATTACHFAIL : Fail (AttachScreen,20L);
break;
case OSERR_NOTAVAILABLE: Fail (ModeNotAvailableError,20L);
break;
default : Fail (UnknownScrError,20L);
break;
}
return NULL;
}
}
else return NULL;
if (Ilbm->Notransb)
{
VideoControlTags (Scr->ViewPort.ColorMap,VTAG_BORDERNOTRANS_SET,TRUE,TAG_END);
MakeScreen (Scr);
RethinkDisplay ();
}
return (Scr);
}
ULONG ModeFallBack (ULONG OldModeID,WORD Width,WORD Height,WORD Depth)
{
ULONG NewModeID = LORES_KEY,BestModeID;
struct TagItem Tags [6];
Tags [0].ti_Tag = BIDTAG_DIPFMustHave;
Tags [0].ti_Data = (OldModeID & HAM ? DIPF_IS_HAM : 0);
Tags [0].ti_Data |= (OldModeID & EXTRA_HALFBRITE ? DIPF_IS_EXTRAHALFBRITE : 0);
Tags [1].ti_Tag = BIDTAG_NominalWidth;
Tags [1].ti_Data = Width; // bmhd->XAspect; // wide;
Tags [2].ti_Tag = BIDTAG_NominalHeight;
Tags [2].ti_Data = Height; // bmhd->YAspectHeight; // high;
Tags [3].ti_Tag = BIDTAG_Depth;
Tags [3].ti_Data = Depth;
Tags [4].ti_Tag = BIDTAG_SourceID;
Tags [4].ti_Data = (FindDisplayInfo (OldModeID) ? OldModeID : (OldModeID & (~(MONITOR_ID_MASK|SPRITES|GENLOCK_AUDIO|GENLOCK_VIDEO|VP_HIDE))));
Tags [5].ti_Tag = TAG_END;
BestModeID = BestModeIDA (Tags);
if (BestModeID != INVALID_ID) NewModeID = BestModeID;
return (NewModeID);
}
VOID ClipIt (WORD wide,WORD high,struct Rectangle *spos,struct Rectangle *dclip,struct Rectangle *txto, struct Rectangle *stdo,struct Rectangle *maxo, struct Rectangle *uclip,BOOL NoCenter)
{
struct Rectangle *besto;
WORD minx, maxx, miny, maxy;
WORD txtw, txth, stdw, stdh, bestw, besth;
/* get the txt, std and max widths and heights */
txtw = txto->MaxX - txto->MinX + 1;
txth = txto->MaxY - txto->MinY + 1;
stdw = stdo->MaxX - stdo->MinX + 1;
stdh = stdo->MaxY - stdo->MinY + 1;
if ((wide <= txtw) && (high <= txth))
{
besto = txto;
bestw = txtw;
besth = txth;
}
else
{
besto = stdo;
bestw = stdw;
besth = stdh;
}
if (uclip)
{
*dclip = *uclip;
spos->MinX = uclip->MinX;
spos->MinY = uclip->MinY;
}
else
{
/* CENTER the screen based on best oscan prefs
* but confine dclip within max oscan limits
*
* FIX MinX first */
spos->MinX = minx = besto->MinX - ((wide - bestw) >> 1);
maxx = wide + minx - 1;
if (maxx > maxo->MaxX) maxx = maxo->MaxX; /* too right */
if (minx < maxo->MinX)
{
minx = maxo->MinX; /* too left */
/* if we want left edge of screen not clipped */
if (NoCenter) spos->MinX = minx;
}
/* FIX MinY */
spos->MinY = miny = besto->MinY - ((high - besth) >> 1);
/* if lower than top of txto, move up */
spos->MinY = miny = MIN (spos->MinY,txto->MinY);
maxy = high + miny - 1;
if (maxy > maxo->MaxY) maxy = maxo->MaxY; /* too down */
if (miny < maxo->MinY)
{
miny = maxo->MinY; /* too up */
/* if we want top of screen not clipped */
if (NoCenter) spos->MinY = miny;
}
/* SET up dclip */
dclip->MinX = minx;
dclip->MinY = miny;
dclip->MaxX = maxx;
dclip->MaxY = maxy;
}
}
LONG MakeDisplay (struct ILBMInfo *Ilbm)
{
if (Ilbm->IFFPFlags & IFFPF_USERMODE) Ilbm->camg = Ilbm->usermodeid;
Ilbm->Bmhd.w = MAX (MIN_WIDTH,Ilbm->Bmhd.w);
Ilbm->Bmhd.h = MAX (MIN_HEIGHT,Ilbm->Bmhd.h);
Ilbm->Bmhd.nPlanes = MIN (MAX_DEPTH,MAX (MIN_DEPTH,Ilbm->Bmhd.nPlanes));
if (ModeNotAvailable (Ilbm->camg) || (Ilbm->IFFPFlags & IFFPF_BESTFIT))
{
Ilbm->camg = ModeFallBack (Ilbm->camg,Ilbm->Bmhd.w,Ilbm->Bmhd.h,Ilbm->Bmhd.nPlanes);
if (ModeNotAvailable (Ilbm->camg))
{
Fail (ModeNotAvailableError,20L);
return NULL;
}
}
if (! (OpenDisplay (Ilbm,MAX (Ilbm->Bmhd.pageWidth,Ilbm->Bmhd.w),MAX (Ilbm->Bmhd.pageHeight,Ilbm->Bmhd.h),Ilbm->Bmhd.nPlanes,Ilbm->camg))) return NULL;
MASK |= SMASK;
MASK |= WMASK;
if (! (VINFO = GetVisualInfo (Ilbm->scr,TAG_END)))
{
Fail (VisualInfoError,20L);
return NULL;
}
MASK |= VMASK;
if (! (LayoutMenus (MAINMENU,VINFO,GTMN_TextAttr,&MYFONTSTRUCT,GTMN_NewLookMenus,TRUE,TAG_END)))
{
Fail (FontError,20L);
return NULL;
}
SetMenuStrip (Ilbm->win,MAINMENU);
return (Ilbm->vp->ColorMap->Count);
}
VOID ShowTime (struct Window *Win,TEXT *String,ULONG Sec)
{
sprintf (BAR_STRING,"%s %uh %um %us",String,Sec / 3600L,(Sec / 60L) % 60L,Sec % 60L);
SetWindowTitles (Win,(TEXT *) ~0,BAR_STRING);
}
VOID SaveCoords (VOID)
{
URMIN = RMIN;
URMAX = RMAX;
UIMIN = IMIN;
UIMAX = IMAX;
}
VOID RestoreCoords (VOID)
{
RMIN = URMIN;
RMAX = URMAX;
IMIN = UIMIN;
IMAX = UIMAX;
}
BOOL NewCoords (struct Window *Win,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
{
long double KReal,KImag;
if (((a2 - a1) < 2L) || ((b2 - b1) < 2L)) return FALSE;
KReal = fabs (RMAX-RMIN) / ((long double) Win->Width);
KImag = fabs (IMAX-IMIN) / ((long double) Win->Height);
SaveCoords ();
RMAX = RMIN + ((long double) a2 * KReal);
IMIN = IMAX - ((long double) b2 * KImag);
RMIN += ((long double) a1 * KReal);
IMAX -= ((long double) b1 * KImag);
return TRUE;
}
VOID AdjustRatio (long double *RMin,long double *IMax,long double *RMax,long double *IMin,WORD ScrWidth,WORD ScrHeight,BOOL KeepReal)
{
long double RWidth,IHeight,RCenter,ICenter;
IHeight = *IMax - *IMin;
RWidth = *RMax - *RMin;
if (KeepReal)
{
ICenter = *IMin + (IHeight / 2.0);
IHeight = (RWidth * ScrHeight) / ScrWidth;
*IMax = ICenter + (IHeight / 2.0);
*IMin = ICenter - (IHeight / 2.0);
}
else
{
RCenter = *RMin + (RWidth / 2.0);
RWidth = (IHeight * ScrWidth) / ScrHeight;
*RMax = RCenter + (RWidth / 2.0);
*RMin = RCenter - (RWidth / 2.0);
}
}
LONG About (struct Window *Win)
{
struct EasyStruct MyReq_1 = { sizeof (struct EasyStruct),0,"Informations requester"," " VERSION COPYRIGHT "\n\n " AUTHOR "\n\n" ADDRESS EMAIL "\n\n\n This program is GiftWare ! \n\n","Ok|More..." };
struct EasyStruct MyReq_2 = { sizeof (struct EasyStruct),0,"Workgroup"," Greetings & thanks to\n\nClaudio Pucci: Debug,Docs,Install\n\nSergio Tassi: Test,Palettes,GUILook\n\nGiuseppe Staffelli: RTG Debug\n\n\n Crime do not pay !\n\n\n Call Double Impact BBS\n\n +39-81-5881319/5889963 24/24h\n\nMultiline ISDN by Paolo Carotenuto\n\n","Ok" };
LONG More;
More = EasyRequest (Win,&MyReq_1,0);
if (! More) EasyRequest (Win,&MyReq_2,0);
return More;
}
LONG Choice (struct Window *Win,TEXT *Title,TEXT *String)
{
struct EasyStruct MyReq = { sizeof (struct EasyStruct),NULL,0,0,"Yes|No" };
MyReq.es_Title = Title;
MyReq.es_TextFormat = String;
return EasyRequest (Win,&MyReq,0);
}
BOOL ShowCoords (struct Window *Win)
{
struct Gadget *GadList = NULL,*StringGad_1,*StringGad_2,*StringGad_3,*StringGad_4;
struct Gadget *MyButtonGad,*MyCheckBoxGad,*MyGad = NULL;
struct Window *GadWin;
struct IntuiMessage *Message;
BOOL NewLimits = FALSE,Exit = FALSE,Accept = FALSE,Reset = FALSE,Ratio = FALSE,KeepReal = TRUE;
TEXT String [MAXCHARS];
UWORD MyCode = 0;
ULONG MyClass = NULL;
long double Tmp_RMIN = RMIN,Tmp_IMAX = IMAX,Tmp_RMAX = RMAX,Tmp_IMIN = IMIN;
TEXTGAD.ng_VisualInfo = BUTTONGAD.ng_VisualInfo = CHECKBOXGAD.ng_VisualInfo = VINFO;
MyCheckBoxGad = CreateContext (&GadList);
CHECKBOXGAD.ng_LeftEdge = 14;
CHECKBOXGAD.ng_TopEdge = 120;
CHECKBOXGAD.ng_Width = 20;
CHECKBOXGAD.ng_Height = 20;
CHECKBOXGAD.ng_GadgetText = "_Keep real limits";
CHECKBOXGAD.ng_Flags = PLACETEXT_RIGHT;
CHECKBOXGAD.ng_GadgetID = KEEP;
MyCheckBoxGad = CreateGadget (CHECKBOX_KIND,MyCheckBoxGad,&CHECKBOXGAD,GTCB_Checked,TRUE,GT_Underscore,'_',TAG_END);
BUTTONGAD.ng_LeftEdge = 14;
BUTTONGAD.ng_TopEdge = 140;
BUTTONGAD.ng_Width = 80;
BUTTONGAD.ng_Height = 20;
BUTTONGAD.ng_GadgetText = "_Accept";
BUTTONGAD.ng_GadgetID = ACCEPT;
MyButtonGad = CreateGadget (BUTTON_KIND,MyCheckBoxGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
BUTTONGAD.ng_LeftEdge += (14 + BUTTONGAD.ng_Width);
BUTTONGAD.ng_GadgetText = "Rat_io";
BUTTONGAD.ng_GadgetID = RATIO;
MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
BUTTONGAD.ng_LeftEdge += (14 + BUTTONGAD.ng_Width);
BUTTONGAD.ng_GadgetText = "Re_set";
BUTTONGAD.ng_GadgetID = RESET;
MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
BUTTONGAD.ng_LeftEdge += (14 + BUTTONGAD.ng_Width);
BUTTONGAD.ng_GadgetText = "_Cancel";
BUTTONGAD.ng_GadgetID = CANCEL;
MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
BUTTONGAD.ng_LeftEdge += (14 + BUTTONGAD.ng_Width);
TEXTGAD.ng_LeftEdge = 54;
TEXTGAD.ng_TopEdge = 14;
TEXTGAD.ng_Width = 268;
TEXTGAD.ng_Height = 14;
TEXTGAD.ng_GadgetText = "_Left";
TEXTGAD.ng_Flags = PLACETEXT_LEFT;
sprintf (String,"%+2.80lf",RMIN);
StringGad_1 = CreateGadget (STRING_KIND,MyButtonGad,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
TEXTGAD.ng_TopEdge += (14 + TEXTGAD.ng_Height);
TEXTGAD.ng_GadgetText = "_Top ";
sprintf (String,"%+2.80lf",IMAX);
StringGad_2 = CreateGadget (STRING_KIND,StringGad_1,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
TEXTGAD.ng_TopEdge += (14 + TEXTGAD.ng_Height);
TEXTGAD.ng_GadgetText = "_Right";
TEXTGAD.ng_Flags = PLACETEXT_RIGHT;
sprintf (String,"%+2.80lf",RMAX);
StringGad_3 = CreateGadget (STRING_KIND,StringGad_2,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
TEXTGAD.ng_TopEdge += (14 + TEXTGAD.ng_Height);
TEXTGAD.ng_GadgetText = "_Bottom";
sprintf (String,"%+2.80lf",IMIN);
StringGad_4 = CreateGadget (STRING_KIND,StringGad_3,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
if (StringGad_4)
{
GadWin = OpenWindowTags (NULL,WA_Left,Win->LeftEdge + 10,
WA_Top,Win->TopEdge + 15,
WA_Width,BUTTONGAD.ng_LeftEdge + 10,
WA_Height,BUTTONGAD.ng_TopEdge + BUTTONGAD.ng_Height + 14 + 15,
WA_Title,"Coordinates requester",
WA_ScreenTitle,"Insert new range...",
WA_CustomScreen,Win->WScreen,
WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY|STRINGIDCMP|BUTTONIDCMP,
WA_Flags,WFLG_ACTIVATE|WFLG_DRAGBAR|WFLG_SIMPLE_REFRESH|WFLG_GIMMEZEROZERO|WFLG_RMBTRAP,
WA_Gadgets,GadList,
TAG_END);
if (GadWin)
{
GT_RefreshWindow (GadWin,NULL);
do { WaitPort (GadWin->UserPort);
if (Message = (struct IntuiMessage *) GT_GetIMsg (GadWin->UserPort))
{
MyGad = (struct Gadget *) Message->IAddress;
MyClass = Message->Class;
MyCode = Message->Code;
GT_ReplyIMsg ((struct IntuiMessage *) Message);
}
switch (MyClass)
{
case IDCMP_REFRESHWINDOW : GT_BeginRefresh (GadWin);
GT_EndRefresh (GadWin,TRUE);
break;
case IDCMP_VANILLAKEY : switch (ToUpper (MyCode))
{
case 'L' : ActivateGadget (StringGad_1,GadWin,0);
break;
case 'T' : ActivateGadget (StringGad_2,GadWin,0);
break;
case 'R' : ActivateGadget (StringGad_3,GadWin,0);
break;
case 'B' : ActivateGadget (StringGad_4,GadWin,0);
break;
case 'A' : Accept = TRUE;
break;
case 'I' : Ratio = TRUE;
break;
case 'S' : Reset = TRUE;
break;
case 'C' : Exit = TRUE;
break;
case 'K' : KeepReal = ! KeepReal;
GT_SetGadgetAttrs (MyCheckBoxGad,GadWin,NULL,GTCB_Checked,KeepReal,TAG_END);
break;
case VAN_ESC: Exit = TRUE;
}
break;
case IDCMP_GADGETUP : switch (MyGad->GadgetID)
{
case ACCEPT: Accept = TRUE;
break;
case RATIO: Ratio = TRUE;
break;
case RESET: Reset = TRUE;
break;
case KEEP: KeepReal = ! KeepReal;
break;
case CANCEL: Exit = TRUE;
}
break;
case IDCMP_CLOSEWINDOW : Exit = TRUE;
}
if (Accept)
{
sscanf (((struct StringInfo *) StringGad_1->SpecialInfo)->Buffer,"%lf",&Tmp_RMIN);
sscanf (((struct StringInfo *) StringGad_2->SpecialInfo)->Buffer,"%lf",&Tmp_IMAX);
sscanf (((struct StringInfo *) StringGad_3->SpecialInfo)->Buffer,"%lf",&Tmp_RMAX);
sscanf (((struct StringInfo *) StringGad_4->SpecialInfo)->Buffer,"%lf",&Tmp_IMIN);
if ((Tmp_RMIN >= Tmp_RMAX) || (Tmp_IMIN >= Tmp_IMAX)) DisplayBeep (Win->WScreen);
else
{
NewLimits = Exit = TRUE;
SaveCoords ();
RMIN = Tmp_RMIN;
IMAX = Tmp_IMAX;
RMAX = Tmp_RMAX;
IMIN = Tmp_IMIN;
}
Accept = FALSE;
}
if (Ratio)
{
AdjustRatio (&Tmp_RMIN,&Tmp_IMAX,&Tmp_RMAX,&Tmp_IMIN,Win->Width,Win->Height,KeepReal);
TEXTGAD.ng_Flags = PLACETEXT_LEFT;
sprintf (String,"%+2.80lf",Tmp_RMIN);
GT_SetGadgetAttrs (StringGad_1,GadWin,NULL,GTST_String,String,TAG_END);
sprintf (String,"%+2.80lf",Tmp_IMAX);
GT_SetGadgetAttrs (StringGad_2,GadWin,NULL,GTST_String,String,TAG_END);
sprintf (String,"%+2.80lf",Tmp_RMAX);
TEXTGAD.ng_Flags = PLACETEXT_RIGHT;
GT_SetGadgetAttrs (StringGad_3,GadWin,NULL,GTST_String,String,TAG_END);
sprintf (String,"%+2.80lf",Tmp_IMIN);
GT_SetGadgetAttrs (StringGad_4,GadWin,NULL,GTST_String,String,TAG_END);
Ratio = FALSE;
}
if (Reset)
{
TEXTGAD.ng_Flags = PLACETEXT_LEFT;
sprintf (String,"%+2.80lf",DEF_RMIN);
GT_SetGadgetAttrs (StringGad_1,GadWin,NULL,GTST_String,String,TAG_END);
sprintf (String,"%+2.80lf",DEF_IMAX);
GT_SetGadgetAttrs (StringGad_2,GadWin,NULL,GTST_String,String,TAG_END);
TEXTGAD.ng_Flags = PLACETEXT_RIGHT;
sprintf (String,"%+2.80lf",DEF_RMAX);
GT_SetGadgetAttrs (StringGad_3,GadWin,NULL,GTST_String,String,TAG_END);
sprintf (String,"%+2.80lf",DEF_IMIN);
GT_SetGadgetAttrs (StringGad_4,GadWin,NULL,GTST_String,String,TAG_END);
Reset = FALSE;
}
} while (Exit == FALSE);
CloseWindow (GadWin);
}
else Fail (WindowGadgetError,15L);
}
else Fail (GadgetError,15L);
FreeGadgets (GadList);
return NewLimits;
}
ULONG IntegerGad (struct Window *Win,TEXT *TitleWin,TEXT *TitleScr,TEXT *TxtString,ULONG Var)
{
struct IntuiMessage *Message;
struct Gadget *GadList = NULL , *MyIntGad , *MyButtonGad , *MyGad = NULL;
struct Window *GadWin;
BOOL Exit = FALSE;
UWORD MyCode = 0;
ULONG MyClass = NULL;
TEXTGAD.ng_VisualInfo = BUTTONGAD.ng_VisualInfo = VINFO;
MyButtonGad = CreateContext (&GadList);
BUTTONGAD.ng_LeftEdge = 20;
BUTTONGAD.ng_TopEdge = 40;
BUTTONGAD.ng_Width = 80;
BUTTONGAD.ng_Height = 20;
BUTTONGAD.ng_GadgetText = "_Accept";
BUTTONGAD.ng_GadgetID = ACCEPT;
MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
BUTTONGAD.ng_LeftEdge += (20 + BUTTONGAD.ng_Width);
BUTTONGAD.ng_GadgetText = "_Cancel";
BUTTONGAD.ng_GadgetID = CANCEL;
MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
TEXTGAD.ng_LeftEdge = 120;
TEXTGAD.ng_TopEdge = 10;
TEXTGAD.ng_Width = 60;
TEXTGAD.ng_Height = 14;
TEXTGAD.ng_GadgetText = TxtString;
TEXTGAD.ng_Flags = PLACETEXT_LEFT;
MyIntGad = CreateGadget (INTEGER_KIND,MyButtonGad,&TEXTGAD,GTIN_Number,Var,GTIN_MaxChars,6,STRINGA_ReplaceMode,TRUE,GT_Underscore,'_',TAG_END);
if (MyIntGad)
{
GadWin = OpenWindowTags (NULL,WA_Left,Win->LeftEdge + 10,
WA_Top,Win->TopEdge + 15,
WA_Width,220,
WA_Height,80,
WA_Title,TitleWin,
WA_ScreenTitle,TitleScr,
WA_CustomScreen,Win->WScreen,
WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY|INTEGERIDCMP|BUTTONIDCMP,
WA_Flags,WFLG_ACTIVATE|WFLG_DRAGBAR|WFLG_SIMPLE_REFRESH|WFLG_GIMMEZEROZERO|WFLG_RMBTRAP,
WA_Gadgets,GadList,
TAG_END);
if (GadWin)
{
GT_RefreshWindow (GadWin,NULL);
do { WaitPort (GadWin->UserPort);
if (Message = (struct IntuiMessage *) GT_GetIMsg (GadWin->UserPort))
{
MyGad = (struct Gadget *) Message->IAddress;
MyClass = Message->Class;
MyCode = Message->Code;
GT_ReplyIMsg ((struct IntuiMessage *) Message);
}
switch (MyClass)
{
case IDCMP_REFRESHWINDOW : GT_BeginRefresh (GadWin);
GT_EndRefresh (GadWin,TRUE);
break;
case IDCMP_VANILLAKEY : switch (ToUpper (MyCode))
{
case 'D' :
case 'I' : ActivateGadget (MyIntGad,GadWin,0);
break;
case 'A' : Var = ((struct StringInfo *) MyIntGad->SpecialInfo)->LongInt;
Exit = TRUE;
break;
case 'C' : Exit = TRUE;
break;
case VAN_ESC: Exit = TRUE;
}
break;
case IDCMP_GADGETUP : switch (MyGad->GadgetID)
{
case ACCEPT : Var = ((struct StringInfo *) MyIntGad->SpecialInfo)->LongInt;
Exit = TRUE;
break;
case CANCEL : Exit = TRUE;
}
break;
case IDCMP_CLOSEWINDOW : Exit = TRUE;
}
} while (Exit == FALSE);
CloseWindow (GadWin);
}
else Fail (WindowError,15L);
}
else Fail (GadgetError,15L);
FreeGadgets (GadList);
return Var;
}
WORD Integer (WORD Iterazioni,long double Cre,long double Cim)
{
return MandInt (Iterazioni,(LONG) (Cre * MAX_POT),(LONG) (Cim * MAX_POT));
}
WORD Real (WORD Iterazioni,long double Cre,long double Cim)
{
long double zr = Cre , zi = Cim , zr2 , zi2;
while (1L)
{
zr2 = zr * zr;
zi2 = zi * zi;
if ((zr2 + zi2) > 4.0) break;
--Iterazioni;
if (Iterazioni == 0) break;
zi *= zr;
zr = zr2 - zi2 + Cre;
zi += zi + Cim;
}
return Iterazioni;
}
VOID VLine_R_EHB (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
{
REGISTER LONG y;
ULONG Color;
CRE = RMIN + (((long double) x) * INCREMREAL);
CIM = IMAX - (((long double) b2) * INCREMIMAG);
for (y = b2; y >= b1; y--)
{
Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
if (Color)
{
Color %= 56L;
Color += 4L;
if (Color > 31L) Color += 4L;
}
SetAPen (Rp,Color);
WritePixel (Rp,x,y);
CIM += INCREMIMAG;
}
}
VOID HLine_R_EHB (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
{
REGISTER LONG x;
ULONG Color;
CRE = RMIN + (((long double) a1) * INCREMREAL);
CIM = IMAX - (((long double) y) * INCREMIMAG);
for (x = a1; x <= a2; x++)
{
Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
if (Color)
{
Color %= 56L;
Color += 4L;
if (Color > 31L) Color += 4L;
}
SetAPen (Rp,Color);
WritePixel (Rp,x,y);
CRE += INCREMREAL;
}
}
VOID VLine_R (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
{
REGISTER LONG y;
ULONG Color;
CRE = RMIN + (((long double) x) * INCREMREAL);
CIM = IMAX - (((long double) b2) * INCREMIMAG);
for (y = b2; y >= b1; y--)
{
Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
if (Color)
{
Color %= COLOR_PENS;
Color += 4L;
}
SetAPen (Rp,Color);
WritePixel (Rp,x,y);
CIM += INCREMIMAG;
}
}
VOID HLine_R (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
{
REGISTER LONG x;
ULONG Color;
CRE = RMIN + (((long double) a1) * INCREMREAL);
CIM = IMAX - (((long double) y) * INCREMIMAG);
for (x = a1; x <= a2; x++)
{
Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
if (Color)
{
Color %= COLOR_PENS;
Color += 4L;
}
SetAPen (Rp,Color);
WritePixel (Rp,x,y);
CRE += INCREMREAL;
}
}
VOID VLine_S_EHB (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
{
REGISTER LONG y;
ULONG Color;
CRE = RMIN + (((long double) x) * INCREMREAL);
CIM = IMAX - (((long double) b2) * INCREMIMAG);
for (y = b2; y >= b1; y--)
{
Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
if (Color)
{
Color *= 56L;
Color /= MAX_ITERATIONS_PLUS_ONE;
Color += 4L;
if (Color > 31L) Color += 4L;
}
SetAPen (Rp,Color);
WritePixel (Rp,x,y);
CIM += INCREMIMAG;
}
}
VOID HLine_S_EHB (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
{
REGISTER LONG x;
ULONG Color;
CRE = RMIN + (((long double) a1) * INCREMREAL);
CIM = IMAX - (((long double) y) * INCREMIMAG);
for (x = a1; x <= a2; x++)
{
Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
if (Color)
{
Color *= 56L;
Color /= MAX_ITERATIONS_PLUS_ONE;
Color += 4L;
if (Color > 31L) Color += 4L;
}
SetAPen (Rp,Color);
WritePixel (Rp,x,y);
CRE += INCREMREAL;
}
}
VOID VLine_S (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
{
REGISTER LONG y;
ULONG Color;
CRE = RMIN + (((long double) x) * INCREMREAL);
CIM = IMAX - (((long double) b2) * INCREMIMAG);
for (y = b2; y >= b1; y--)
{
Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
if (Color)
{
Color *= COLOR_PENS;
Color /= MAX_ITERATIONS_PLUS_ONE;
Color += 4L;
}
SetAPen (Rp,Color);
WritePixel (Rp,x,y);
CIM += INCREMIMAG;
}
}
VOID HLine_S (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
{
REGISTER LONG x;
ULONG Color;
CRE = RMIN + (((long double) a1) * INCREMREAL);
CIM = IMAX - (((long double) y) * INCREMIMAG);
for (x = a1; x <= a2; x++)
{
Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
if (Color)
{
Color *= COLOR_PENS;
Color /= MAX_ITERATIONS_PLUS_ONE;
Color += 4L;
}
SetAPen (Rp,Color);
WritePixel (Rp,x,y);
CRE += INCREMREAL;
}
}
BOOL CheckBox (struct RastPort *Rp,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
{
const LONG Color = ReadPixel (Rp,a1,b1);
REGISTER LONG Var;
if (Color != ReadPixel (Rp,a2,b2)) return FALSE;
if (Color != ReadPixel (Rp,a2,b1)) return FALSE;
if (Color != ReadPixel (Rp,a1,b2)) return FALSE;
for (Var = (a1 + 1L); Var <= (a2 - 1L); Var++)
{
if (Color != ReadPixel (Rp,Var,b1)) return FALSE;
if (Color != ReadPixel (Rp,Var,b2)) return FALSE;
}
for (Var = (b1 + 1L); Var <= (b2 - 1L); Var++)
{
if (Color != ReadPixel (Rp,a1,Var)) return FALSE;
if (Color != ReadPixel (Rp,a2,Var)) return FALSE;
}
return TRUE;
}
BOOL Rectangle (struct Window *Win,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
{
struct IntuiMessage *Message;
UWORD MyCode;
LONG helpx,helpy;
ULONG MyClass;
if (Win->UserPort->mp_SigBit)
{
if (Message = (struct IntuiMessage *) GT_GetIMsg (Win->UserPort))
{
MyClass = Message->Class;
MyCode = Message->Code;
GT_ReplyIMsg ((struct IntuiMessage *) Message);
switch (MyClass)
{
case IDCMP_MENUPICK : if (MyCode != MENUNULL)
{
if (ProcessMenu (Win,MyCode) & STOP_MSG) return TRUE;
}
break;
case IDCMP_RAWKEY : if (MyCode == TAB) return FALSE;
if (MyCode == RAW_ESC) return TRUE;
break;
case IDCMP_CLOSEWINDOW : return TRUE;
}
}
}
helpx = a2 - a1;
helpy = b2 - b1;
if ((helpx < MINLIMIT) || (helpy < MINLIMIT)) return FALSE;
if (CheckBox (Win->RPort,a1,b1,a2,b2))
{
SetAPen (Win->RPort,ReadPixel (Win->RPort,a1,b1));
RectFill (Win->RPort,a1,b1,a2,b2);
return FALSE;
}
if ((helpx < (MINLIMIT << 1L)) || (helpy < (MINLIMIT << 1L)))
{
for (helpy = (b1 + 1L); helpy <= (b2 - 1L); helpy++)
{
H_LINE (Win->RPort,a1+1L,a2-1L,helpy);
}
return FALSE;
}
if (helpx >= helpy)
{
helpx = (a1 + a2) >> 1L;
V_LINE (Win->RPort,b1+1L,b2-1L,helpx);
if (Rectangle (Win,a1,b1,helpx,b2)) return TRUE;
if (Rectangle (Win,helpx,b1,a2,b2)) return TRUE;
}
else
{
helpy = (b1 + b2) >> 1L;
H_LINE (Win->RPort,a1+1L,a2-1L,helpy);
if (Rectangle (Win,a1,b1,a2,helpy)) return TRUE;
if (Rectangle (Win,a1,helpy,a2,b2)) return TRUE;
}
return FALSE;
}
ULONG DrawFractal (struct Window *Win,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
{
ULONG StartSec = NULL , EndSec = NULL , Dummy = NULL;
CurrentTime (&StartSec,&Dummy);
INCREMREAL = (fabs (RMAX-RMIN)) / ((long double) (a2 - a1 + 1L));
INCREMIMAG = (fabs (IMAX-IMIN)) / ((long double) (b2 - b1 + 1L));
MAX_ITERATIONS_PLUS_ONE = MAX_ITERATIONS + 1;
if (TMASK & MASK) ShowTitle (Win->WScreen,FALSE);
H_LINE (Win->RPort,a1,a2,b1);
V_LINE (Win->RPort,b1+1L,b2-1L,a2);
H_LINE (Win->RPort,a1,a2,b2);
V_LINE (Win->RPort,b1+1L,b2-1L,a1);
Rectangle (Win,a1,b1,a2,b2);
if (TMASK & MASK) ShowTitle (Win->WScreen,TRUE);
CurrentTime (&EndSec,&Dummy);
return (EndSec-StartSec);
}
BOOL Preview (struct Window *Win,const LONG Width,const LONG Height)
{
struct Window *PreviewWin;
struct IntuiMessage *Message;
BOOL Error = FALSE;
UWORD MyCode = 0;
ULONG MyClass = NULL;
MYBITMAP = CopyBitMap (Win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
PreviewWin = OpenWindowTags (0,WA_Left,Win->LeftEdge + 10,
WA_Top,Win->TopEdge + 15,
WA_Width,(WORD) (Width >> 1L),
WA_Height,(WORD) (Height >> 1L),
WA_Title,"Preview window",
WA_ScreenTitle,"¼ Window preview...",
WA_CustomScreen,Win->WScreen,
WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW,
WA_Flags,WFLG_ACTIVATE|WFLG_CLOSEGADGET|WFLG_DRAGBAR|WFLG_NOCAREREFRESH|WFLG_SMART_REFRESH|WFLG_RMBTRAP|WFLG_GIMMEZEROZERO,
TAG_END);
if (PreviewWin)
{
PasteWin (MYBITMAP,PreviewWin,ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
PutPointer (PreviewWin,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
ELAPSEDTIME = DrawFractal (PreviewWin,0L,0L,(LONG) (PreviewWin->GZZWidth) - 1L,(LONG) (PreviewWin->GZZHeight) - 1L);
PutPointer (PreviewWin,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
ShowTime (Win,"Preview elapsed time:",ELAPSEDTIME);
while (1L)
{
WaitPort (PreviewWin->UserPort);
if (Message = (struct IntuiMessage *) GT_GetIMsg (PreviewWin->UserPort))
{
MyClass = Message->Class;
MyCode = Message->Code;
GT_ReplyIMsg ((struct IntuiMessage *) Message);
}
if (MyClass == IDCMP_CLOSEWINDOW) break;
if ((MyClass == IDCMP_RAWKEY) && (MyCode == RAW_ESC)) break;
}
PutPointer (PreviewWin,0,0,0,0,0,0);
CloseWindow (PreviewWin);
}
else
{
if (BMASK & MASK)
{
FreeBitMap (MYBITMAP);
MASK ^= BMASK;
}
Fail (PreviewWindowError,15L);
Error = TRUE;
}
return Error;
}
BOOL DrawFrame (struct Window *Win,WORD Zx,WORD Zy,WORD Zw,WORD Zh)
{
WORD LeftEdge,TopEdge,RightEdge,BottomEdge;
if ((Zx > 2) && (Zy > 2) && (Zx < Win->Width - 2) && (Zy < Win->Height - 2) && ((Zw >= INITIALZOOM) || (Zh >= INITIALZOOM)))
{
LeftEdge = Zx - Zw;
TopEdge = Zy - Zh;
RightEdge = Zx + Zw;
BottomEdge = Zy + Zh;
if ((LeftEdge >= 0) && (TopEdge >= 0) && (RightEdge <= Win->Width) && (BottomEdge <= Win->Height))
{
ZOOMLINE [8] = ZOOMLINE [0] = ZOOMLINE [6] = LeftEdge;
ZOOMLINE [1] = ZOOMLINE [3] = TopEdge;
ZOOMLINE [2] = ZOOMLINE [4] = RightEdge;
ZOOMLINE [5] = ZOOMLINE [7] = BottomEdge;
ZOOMLINE [9] = ZOOMLINE [1] + 1;
}
DrawBorder (Win->RPort,&MYBORDER,0,0);
MASK |= ZMASK;
}
else MASK ^= ZMASK;
return (BOOL) (ZMASK & MASK);
}
BOOL FileRequest (struct Window *Win,TEXT *String,BOOL Mode,BOOL Type)
{
struct FileRequester *MyFileReq;
BOOL Success = FALSE;
if (MyFileReq = AllocAslRequest (ASL_FileRequest,0))
{
if (Mode) strcpy (MYDIR,"PROGDIR:Pictures");
else strcpy (MYDIR,"PROGDIR:Palettes");
if (AslRequestTags (MyFileReq,ASLFR_Window,Win,
ASLFR_InitialLeftEdge,Win->LeftEdge + 15,
ASLFR_InitialTopEdge,Win->TopEdge + 25,
ASLFR_InitialWidth,300,
ASLFR_InitialHeight,((Win->Height) * 7) >> 3,
ASLFR_SleepWindow,TRUE,
ASLFR_TextAttr,&MYFONTSTRUCT,
ASLFR_TitleText,String,
ASLFR_InitialDrawer,MYDIR,
ASLFR_InitialFile,MYFILE,
ASLFR_DoSaveMode,Type,
ASLFR_RejectIcons,TRUE,
TAG_END))
{
strcpy (MYFILE,MyFileReq->rf_File);
strcpy (MYDIR,MyFileReq->rf_Dir);
strcpy (MYPATH,MYDIR);
Success = AddPart (MYPATH,MYFILE,sizeof (MYPATH));
}
FreeAslRequest (MyFileReq);
}
return Success;
}
BOOL FontRequest (struct Window *Win)
{
struct FontRequester *MyFontReq;
BOOL Success = FALSE;
if (MyFontReq = AllocAslRequest (ASL_FontRequest,0))
{
if (AslRequestTags (MyFontReq,ASLFO_Window,Win,
ASLFO_InitialLeftEdge,Win->LeftEdge + 15,
ASLFO_InitialTopEdge,Win->TopEdge + 25,
ASLFO_InitialWidth,300,
ASLFO_InitialHeight,((Win->Height) * 7) >> 3,
ASLFO_SleepWindow,TRUE,
ASLFO_TextAttr,&MYFONTSTRUCT,
ASLFO_TitleText,"Font requester",
ASLFO_InitialName,MYFONTSTRUCT.ta_Name,
ASLFO_InitialSize,MYFONTSTRUCT.ta_YSize,
ASLFO_InitialStyle,MYFONTSTRUCT.ta_Style,
ASLFO_InitialFlags,MYFONTSTRUCT.ta_Flags,
ASLFO_DoFrontPen,TRUE,
ASLFO_DoBackPen,TRUE,
ASLFO_DoStyle,TRUE,
ASLFO_DoDrawMode,TRUE,
ASLFO_MinHeight,8,
TAG_END))
{
strcpy (MYFONTSTRUCT.ta_Name,MyFontReq->fo_Attr.ta_Name);
MYFONTSTRUCT.ta_YSize = MyFontReq->fo_Attr.ta_YSize;
MYFONTSTRUCT.ta_Style = MyFontReq->fo_Attr.ta_Style;
MYFONTSTRUCT.ta_Flags = MyFontReq->fo_Attr.ta_Flags;
Success = TRUE;
}
FreeAslRequest (MyFontReq);
}
return Success;
}
BOOL SMRequest (struct ILBMInfo *Ilbm)
{
struct ScreenModeRequester *SMReq;
struct Window *Win = Ilbm->win;
BOOL NewScreen = FALSE;
if (SMReq = AllocAslRequest (ASL_ScreenModeRequest,NULL))
{
if (AslRequestTags (SMReq,ASLSM_Window,Win,
ASLSM_SleepWindow,TRUE,
ASLSM_TitleText,"ScreenMode requester",
ASLSM_InitialLeftEdge,Win->LeftEdge + 15,
ASLSM_InitialTopEdge,Win->TopEdge + 25,
ASLSM_InitialWidth,310,
ASLSM_InitialHeight,((Win->Height) * 7) >> 3,
ASLSM_InitialDisplayID,GetVPModeID (ViewPortAddress (Win)),
ASLSM_InitialDisplayWidth,Win->Width,
ASLSM_InitialDisplayHeight,Win->Height,
ASLSM_InitialDisplayDepth,Win->RPort->BitMap->Depth,
ASLSM_InitialOverscanType,Ilbm->ucliptype,
ASLSM_DoWidth,TRUE,
ASLSM_DoHeight,TRUE,
ASLSM_DoDepth,TRUE,
ASLSM_DoOverscanType,TRUE,
ASLSM_MinDepth,MIN_DEPTH,
ASLSM_MaxDepth,MAX_DEPTH,
ASLSM_PropertyFlags,DIPF_IS_WB|DIPF_IS_EXTRAHALFBRITE,
ASLSM_PropertyMask,DIPF_IS_DUALPF|DIPF_IS_PF2PRI|DIPF_IS_HAM,
ASLSM_MinWidth,MIN_WIDTH,
ASLSM_MinHeight,MIN_HEIGHT,
TAG_END))
{
Ilbm->camg = SMReq->sm_DisplayID;
Ilbm->Bmhd.w = SMReq->sm_DisplayWidth;
Ilbm->Bmhd.h = SMReq->sm_DisplayHeight;
Ilbm->Bmhd.nPlanes = SMReq->sm_DisplayDepth;
Ilbm->ucliptype = SMReq->sm_OverscanType;
NewScreen = TRUE;
}
FreeAslRequest (SMReq);
}
return NewScreen;
}
VOID SetMenuStart (struct Window *Win)
{
OnMenu (Win,FULLMENUNUM (0,0,NOSUB));
OnMenu (Win,FULLMENUNUM (0,2,NOSUB));
OnMenu (Win,FULLMENUNUM (0,3,NOSUB));
OnMenu (Win,FULLMENUNUM (0,4,NOSUB));
OnMenu (Win,FULLMENUNUM (0,5,NOSUB));
OnMenu (Win,FULLMENUNUM (0,7,NOSUB));
OnMenu (Win,FULLMENUNUM (0,9,NOSUB));
OnMenu (Win,FULLMENUNUM (1,0,NOSUB));
OnMenu (Win,FULLMENUNUM (1,1,NOSUB));
OnMenu (Win,FULLMENUNUM (1,2,NOSUB));
OnMenu (Win,FULLMENUNUM (1,4,NOSUB));
OnMenu (Win,FULLMENUNUM (2,2,NOSUB));
OnMenu (Win,FULLMENUNUM (2,4,NOSUB));
OffMenu (Win,FULLMENUNUM (2,7,NOSUB));
OnMenu (Win,FULLMENUNUM (3,0,NOSUB));
OnMenu (Win,FULLMENUNUM (3,2,NOSUB));
OnMenu (Win,FULLMENUNUM (3,4,NOSUB));
OnMenu (Win,FULLMENUNUM (3,6,NOSUB));
}
VOID SetMenuStop (struct Window *Win)
{
OffMenu (Win,FULLMENUNUM (0,0,NOSUB));
OffMenu (Win,FULLMENUNUM (0,2,NOSUB));
OffMenu (Win,FULLMENUNUM (0,3,NOSUB));
OffMenu (Win,FULLMENUNUM (0,4,NOSUB));
OffMenu (Win,FULLMENUNUM (0,5,NOSUB));
OffMenu (Win,FULLMENUNUM (0,7,NOSUB));
OffMenu (Win,FULLMENUNUM (0,9,NOSUB));
OffMenu (Win,FULLMENUNUM (1,0,NOSUB));
OffMenu (Win,FULLMENUNUM (1,1,NOSUB));
OffMenu (Win,FULLMENUNUM (1,2,NOSUB));
OffMenu (Win,FULLMENUNUM (1,4,NOSUB));
OffMenu (Win,FULLMENUNUM (2,0,NOSUB));
OffMenu (Win,FULLMENUNUM (2,2,NOSUB));
OffMenu (Win,FULLMENUNUM (2,4,NOSUB));
OffMenu (Win,FULLMENUNUM (2,6,NOSUB));
OnMenu (Win,FULLMENUNUM (2,7,NOSUB));
OffMenu (Win,FULLMENUNUM (3,0,NOSUB));
OffMenu (Win,FULLMENUNUM (3,2,NOSUB));
OffMenu (Win,FULLMENUNUM (3,4,NOSUB));
OffMenu (Win,FULLMENUNUM (3,6,NOSUB));
}
ULONG ProcessMenu (struct Window *Win,UWORD Code)
{
struct MenuItem *Item;
ULONG Choice = NULL;
while (Code != MENUNULL)
{
Item = ItemAddress (MAINMENU,Code);
switch (MENUNUM (Code))
{
case 0: switch (ITEMNUM (Code))
{
case 0: Choice |= ABOUT_MSG;
break;
case 2: Choice |= LOADPICTURE_MSG;
break;
case 3: Choice |= SAVEPICTURE_MSG;
break;
case 4: Choice |= LOADPALETTE_MSG;
break;
case 5: Choice |= SAVEPALETTE_MSG;
break;
case 7: Choice |= DUMP_MSG;
break;
case 9: Choice |= EXIT_MSG;
break;
}
break;
case 1: switch (ITEMNUM (Code))
{
case 0: switch (SUBNUM (Code))
{
case 0: Choice |= TITLE_MSG;
break;
case 2: Choice |= TIME_MSG;
break;
}
break;
case 1: Choice |= COORDS_MSG;
break;
case 2: switch (SUBNUM (Code))
{
case 0: MAX_ITERATIONS = 63;
break;
case 1: MAX_ITERATIONS = 127;
break;
case 2: MAX_ITERATIONS = 191;
break;
case 3: MAX_ITERATIONS = 255;
break;
case 4: MAX_ITERATIONS = 319;
break;
case 5: MAX_ITERATIONS = 383;
break;
case 6: MAX_ITERATIONS = 447;
break;
case 7: MAX_ITERATIONS = 511;
break;
case 8: MAX_ITERATIONS = 1023;
break;
case 10: Choice |= ITER_MSG;
break;
}
break;
case 3: switch (SUBNUM (Code))
{
case 0: PRIORITY = -5;
break;
case 1: PRIORITY = -4;
break;
case 2: PRIORITY = -3;
break;
case 3: PRIORITY = -2;
break;
case 4: PRIORITY = -1;
break;
case 6: PRIORITY = 0;
break;
case 8: PRIORITY = 1;
break;
case 9: PRIORITY = 2;
break;
case 10: PRIORITY = 3;
break;
case 11: PRIORITY = 4;
break;
case 12: PRIORITY = 5;
break;
}
Forbid ();
THISTASK = FindTask (NULL);
Permit ();
SetTaskPri (THISTASK,PRIORITY);
break;
case 4: switch (SUBNUM (Code))
{
case 0: if (CheckEHB (MYILBM.camg))
{
H_LINE = HLine_R_EHB;
V_LINE = VLine_R_EHB;
}
else
{
H_LINE = HLine_R;
V_LINE = VLine_R;
}
SPREAD = FALSE;
break;
case 1: if (CheckEHB (MYILBM.camg))
{
H_LINE = HLine_S_EHB;
V_LINE = VLine_S_EHB;
}
else
{
H_LINE = HLine_S;
V_LINE = VLine_S;
}
SPREAD = TRUE;
break;
}
break;
case 5: switch (SUBNUM (Code))
{
case 0: FUNCTION = Integer;
break;
case 1: FUNCTION = Real;
break;
}
break;
}
break;
case 2: switch (ITEMNUM (Code))
{
case 0: Choice |= PREVIEW_MSG;
break;
case 2: Choice |= REDRAW_MSG;
break;
case 4: Choice |= UNDO_MSG;
break;
case 6: Choice |= DRAW_MSG;
break;
case 7: Choice |= STOP_MSG;
break;
}
break;
case 3: switch (ITEMNUM (Code))
{
case 0: switch (SUBNUM (Code))
{
case 0: Choice |= CYCLERIGHT_MSG;
break;
case 1: Choice |= CYCLELEFT_MSG;
break;
case 3: Choice |= DELAY_MSG;
break;
}
break;
case 2: Choice |= PALETTE_MSG;
break;
case 4: Choice |= NEWDISPLAY_MSG;
break;
case 6: Choice |= FONTREQ_MSG;
break;
}
}
Code = Item->NextSelect;
}
return Choice;
}
VOID ProcessMouse (struct Window *Win,WORD CurMouseX,WORD CurMouseY)
{
static WORD MX1 = 0 , MY1 = 0 , MX2 = 0 , MY2 = 0 , W = 0 , H = 0;
struct IntuiMessage *Message;
UWORD MyCode = 0,DefaultQueue;
ULONG MyClass = NULL;
ModifyIDCMP (Win,IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE);
DefaultQueue = SetMouseQueue (Win,10);
if (ZMASK & MASK) DrawFrame (Win,MX1,MY1,W,H);
MX1 = CurMouseX;
MY1 = CurMouseY;
W = INITIALZOOM;
H = ScalerDiv (W,Win->Height,Win->Width);
DrawFrame (Win,MX1,MY1,W,H);
while (1L)
{
WaitPort (Win->UserPort);
if (Message = (struct IntuiMessage *) GT_GetIMsg (Win->UserPort))
{
MyClass = Message->Class;
MyCode = Message->Code;
MX2 = Message->MouseX;
MY2 = Message->MouseY;
GT_ReplyIMsg ((struct IntuiMessage *) Message);
}
if (MyClass == IDCMP_MOUSEMOVE)
{
DrawFrame (Win,MX1,MY1,W,H);
W = abs (MX1 - MX2);
H = abs (MY1 - MY2);
if (W > H) (W = ScalerDiv (H,Win->Width,Win->Height));
else (H = ScalerDiv (W,Win->Height,Win->Width));
DrawFrame (Win,MX1,MY1,W,H);
}
else if ((MyClass == IDCMP_MOUSEBUTTONS) && (MyCode != SELECTDOWN)) break;
}
SetMouseQueue (Win,DefaultQueue);
ModifyIDCMP (Win,IDCMP_STANDARD);
if (ZMASK & MASK)
{
OnMenu (Win,FULLMENUNUM (2,0,NOSUB));
OnMenu (Win,FULLMENUNUM (2,6,NOSUB));
}
else
{
OffMenu (Win,FULLMENUNUM (2,0,NOSUB));
OffMenu (Win,FULLMENUNUM (2,6,NOSUB));
}
}
ULONG HandleEvents (struct ILBMInfo *Ilbm)
{
struct IntuiMessage *Message;
WORD MouseX = 0,MouseY = 0;
UWORD MyCode = 0,Index;
LONG Error;
ULONG MyClass = NULL,MyMenu = NULL;
double RealCoord,ImagCoord,RealDist,ImagDist,Kre,Kim,ScrRatio,FracRatio;
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
RealDist = fabs (RMAX-RMIN);
ImagDist = fabs (IMAX-IMIN);
Kre = RealDist / (double) (Ilbm->win->Width - 1);
Kim = ImagDist / (double) (Ilbm->win->Height - 1);
ScrRatio = (double) Ilbm->win->Width / (double) Ilbm->win->Height;
FracRatio = RealDist / ImagDist;
do { WaitPort (Ilbm->win->UserPort);
if (Message = (struct IntuiMessage *) GT_GetIMsg (Ilbm->win->UserPort))
{
MyClass = Message->Class;
MyCode = Message->Code;
MouseX = Message->MouseX;
MouseY = Message->MouseY;
GT_ReplyIMsg ((struct IntuiMessage *) Message);
}
switch (MyClass)
{
case IDCMP_MOUSEMOVE: if (TMASK & MASK)
{
RealCoord = RMIN + (double) MouseX * Kre;
ImagCoord = IMAX - (double) MouseY * Kim;
sprintf (BAR_STRING,"Real %+2.16lf Imag %+2.16lfi W:H %.5lf R:I %.5lf",RealCoord,ImagCoord,ScrRatio,FracRatio);
WaitTOF ();
SetWindowTitles (Ilbm->win,(TEXT *) ~0,BAR_STRING);
}
break;
case IDCMP_MOUSEBUTTONS: if (MyCode == SELECTDOWN) ProcessMouse (Ilbm->win,MouseX,MouseY);
break;
case IDCMP_MENUPICK: MyMenu = ProcessMenu (Ilbm->win,MyCode);
if (MyMenu & EXIT_MSG) break;
if (MyMenu & TITLE_MSG)
{
if (TMASK & MASK) MASK ^= TMASK;
else MASK |= TMASK;
Ilbm->TBState = TMASK & MASK;
ShowTitle (Ilbm->scr,Ilbm->TBState);
break;
}
if (MyMenu & TIME_MSG)
{
if (! (TMASK & MASK)) ShowTitle (Ilbm->scr,TRUE);
ShowTime (Ilbm->win,"Last calculating time:",ELAPSEDTIME);
Delay (MYSECS);
if (! (TMASK & MASK)) ShowTitle (Ilbm->scr,FALSE);
break;
}
if (MyMenu & ITER_MSG)
{
ModifyIDCMP (Ilbm->win,NULL);
ClearMenuStrip (Ilbm->win);
while (1L)
{
MAX_ITERATIONS = (WORD) IntegerGad (Ilbm->win,"Iterations requester","Insert new iterations...","_Iterations",MAX_ITERATIONS + 1L) - 1L;
if (MAX_ITERATIONS >= 15L) break;
DisplayBeep (Ilbm->scr);
}
ResetMenuStrip (Ilbm->win,MAINMENU);
ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
break;
}
if (MyMenu & ABOUT_MSG)
{
ModifyIDCMP (Ilbm->win,NULL);
ClearMenuStrip (Ilbm->win);
About (Ilbm->win);
ResetMenuStrip (Ilbm->win,MAINMENU);
ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
break;
}
if (MyMenu & PALETTE_MSG)
{
ModifyIDCMP (Ilbm->win,NULL);
ClearMenuStrip (Ilbm->win);
if (! ModifyPalette (Ilbm->win,Ilbm->win->LeftEdge + 10,Ilbm->win->TopEdge + 15,300,185,PALETTE)) Fail (PaletteRequesterError,15L);
ResetMenuStrip (Ilbm->win,MAINMENU);
ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
break;
}
if (MyMenu & CYCLERIGHT_MSG)
{
ModifyIDCMP (Ilbm->win,IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY|IDCMP_MENUPICK);
if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
ClearMenuStrip (Ilbm->win);
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
Cycle (Ilbm->win,DELAY,SHIFTRIGHT);
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
ResetMenuStrip (Ilbm->win,MAINMENU);
if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
LoadRGB32 (ViewPortAddress (Ilbm->win),PALETTE);
ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
break;
}
if (MyMenu & CYCLELEFT_MSG)
{
ModifyIDCMP (Ilbm->win,IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY|IDCMP_MENUPICK);
if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
ClearMenuStrip (Ilbm->win);
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
Cycle (Ilbm->win,DELAY,SHIFTLEFT);
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
ResetMenuStrip (Ilbm->win,MAINMENU);
if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
LoadRGB32 (ViewPortAddress (Ilbm->win),PALETTE);
ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
break;
}
if (MyMenu & DELAY_MSG)
{
while (1L)
{
DELAY = IntegerGad (Ilbm->win,"Delay requester","Insert delay time...","_Delay time",DELAY);
if (DELAY >= 0L) break;
DisplayBeep (Ilbm->scr);
}
break;
}
if (MyMenu & STOP_MSG)
{
SetMenuStart (Ilbm->win);
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
break;
}
if (MyMenu & LOADPICTURE_MSG)
{
if (FileRequest (Ilbm->win,"Load iff picture",PICTURE_MODE,FALSE))
{
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
if (Ilbm->ParseInfo.iff = AllocIFF ())
{
if (! (Error = QueryMandPic (Ilbm,&MANDChunkTmp,MYPATH)))
{
MANDChunk = *MANDChunkTmp;
SaveCoords ();
RMIN = MANDChunk.RMin;
RMAX = MANDChunk.RMax;
IMIN = MANDChunk.IMin;
IMAX = MANDChunk.IMax;
MAX_ITERATIONS = MANDChunk.Iterations - 1L;
RealDist = fabs (RMAX-RMIN);
ImagDist = fabs (IMAX-IMIN);
Kre = RealDist / (double) (Ilbm->win->Width - 1);
Kim = ImagDist / (double) (Ilbm->win->Height - 1);
FracRatio = RealDist / ImagDist;
if (MANDChunk.Special & SPREAD_BIT) SPREAD = TRUE;
else SPREAD = FALSE;
if (MANDChunk.Special & INTEGER_BIT) FUNCTION = Integer;
else FUNCTION = Real;
CloseDisplay (Ilbm,VINFO);
Ilbm->IFFPFlags = IFFPF_BESTFIT;
COLOR_PENS = MakeDisplay (Ilbm);
Ilbm->IFFPFlags = NULL;
if (! COLOR_PENS)
{
Fail (MakeDisplayError,20L);
MyMenu = EXIT_MSG;
break;
}
if (ZMASK & MASK) MASK ^= ZMASK;
COLOR_PENS -= 4L;
if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
if (LoadMandPic (Ilbm,MYPATH)) Fail (LoadMandPicError,5L);
if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
if (CheckEHB (Ilbm->camg)) GetRGB32 (Ilbm->vp->ColorMap,0L,32L,&PALETTE [1L]);
else GetRGB32 (Ilbm->vp->ColorMap,0L,Ilbm->vp->ColorMap->Count,&PALETTE [1L]);
LoadRGB32 (Ilbm->vp,PALETTE);
ClearMenuStrip (Ilbm->win);
if (SPREAD)
{
if (ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags ^= CHECKED;
if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags |= CHECKED;
if (CheckEHB (MYILBM.camg))
{
H_LINE = HLine_S_EHB;
V_LINE = VLine_S_EHB;
}
else
{
H_LINE = HLine_S;
V_LINE = VLine_S;
}
}
else
{
if (ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags ^= CHECKED;
if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags |= CHECKED;
if (CheckEHB (MYILBM.camg))
{
H_LINE = HLine_R_EHB;
V_LINE = VLine_R_EHB;
}
else
{
H_LINE = HLine_R;
V_LINE = VLine_R;
}
}
for (Index = 0; Index <= 10; Index++) if (ItemAddress (MAINMENU,FULLMENUNUM (1,2,Index))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,2,Index))->Flags ^= CHECKED;
switch (MAX_ITERATIONS)
{
case 63 : if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,0))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,0))->Flags |= CHECKED;
break;
case 127: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,1))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,1))->Flags |= CHECKED;
break;
case 191: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,2))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,2))->Flags |= CHECKED;
break;
case 255: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,3))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,3))->Flags |= CHECKED;
break;
case 319: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,4))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,4))->Flags |= CHECKED;
break;
case 383: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,5))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,5))->Flags |= CHECKED;
break;
case 447: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,6))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,6))->Flags |= CHECKED;
break;
case 511: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,7))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,7))->Flags |= CHECKED;
break;
case 1023: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,8))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,8))->Flags |= CHECKED;
break;
default: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,10))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,10))->Flags |= CHECKED;
break;
}
if (FUNCTION == Integer)
{
if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags ^= CHECKED;
if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags |= CHECKED;
}
else
{
if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags ^= CHECKED;
if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags |= CHECKED;
}
ResetMenuStrip (Ilbm->win,MAINMENU);
}
else Fail (QueryMandPicError,NULL);
FreeIFF (Ilbm->ParseInfo.iff);
}
}
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
break;
}
if (MyMenu & SAVEPICTURE_MSG)
{
if (FileRequest (Ilbm->win,"Save iff picture",PICTURE_MODE,TRUE))
{
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
if (Ilbm->ParseInfo.iff = AllocIFF ())
{
MANDChunk.LeftEdge = Ilbm->win->LeftEdge;
MANDChunk.TopEdge = Ilbm->win->TopEdge;
MANDChunk.Width = Ilbm->win->Width;
MANDChunk.Height = Ilbm->win->Height;
MANDChunk.RMin = RMIN;
MANDChunk.RMax = RMAX;
MANDChunk.IMin = IMIN;
MANDChunk.IMax = IMAX;
MANDChunk.Iterations = MAX_ITERATIONS + 1L;
MANDChunk.Special = NULL;
if (SPREAD) MANDChunk.Special |= SPREAD_BIT;
if (FUNCTION == Integer) MANDChunk.Special |= INTEGER_BIT;
if (ZMASK & MASK)
{
DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
MASK ^= ZMASK;
}
if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
if (SaveMandPic (Ilbm,&SPECIAL_CHUNK,©RIGHT_CHUNK,MYPATH)) Fail (SaveMandPicError,5L);
if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
FreeIFF (Ilbm->ParseInfo.iff);
}
}
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
break;
}
if (MyMenu & LOADPALETTE_MSG)
{
if (FileRequest (Ilbm->win,"Load palette",PALETTE_MODE,FALSE))
{
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
if (Ilbm->ParseInfo.iff = AllocIFF ())
{
LoadPalette (Ilbm,MYPATH);
if (CheckEHB (Ilbm->camg)) GetRGB32 (Ilbm->vp->ColorMap,0L,32L,&PALETTE [1L]);
else GetRGB32 (Ilbm->vp->ColorMap,0L,Ilbm->vp->ColorMap->Count,&PALETTE [1L]);
LoadRGB32 (Ilbm->vp,PALETTE);
FreeIFF (Ilbm->ParseInfo.iff);
}
}
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
break;
}
if (MyMenu & SAVEPALETTE_MSG)
{
if (FileRequest (Ilbm->win,"Save palette",PALETTE_MODE,TRUE))
{
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
if (Ilbm->ParseInfo.iff = AllocIFF ())
{
SavePalette (Ilbm,©RIGHT_CHUNK,MYPATH);
FreeIFF (Ilbm->ParseInfo.iff);
}
}
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
break;
}
if (MyMenu & FONTREQ_MSG)
{
if (FontRequest (Ilbm->win))
{
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
MYBITMAP = CopyBitMap (Ilbm->win,0,0,Ilbm->win->Width,Ilbm->win->Height);
CloseDisplay (Ilbm,VINFO);
if (NEWFONT = OpenDiskFont (&MYFONTSTRUCT)) MASK |= FMASK;
else
{
strcpy (MYFONTSTRUCT.ta_Name,"topaz.font");
MYFONTSTRUCT.ta_YSize = 8;
MYFONTSTRUCT.ta_Style = FS_NORMAL;
MYFONTSTRUCT.ta_Flags = FPF_ROMFONT;
}
MakeDisplay (Ilbm);
PasteWin (MYBITMAP,Ilbm->win,Ilbm->win->Width,Ilbm->win->Height);
}
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
break;
}
if (MyMenu & DUMP_MSG)
{
ModifyIDCMP (Ilbm->win,NULL);
ClearMenuStrip (Ilbm->win);
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
if (Choice (Ilbm->win,"Print requester","Are you sure ?"))
{
WinDump (Ilbm->win);
}
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
ResetMenuStrip (Ilbm->win,MAINMENU);
ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
break;
}
if (MyMenu & PREVIEW_MSG)
{
if (NewCoords (Ilbm->win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4],ZOOMLINE [5]))
{
ModifyIDCMP (Ilbm->win,NULL);
ClearMenuStrip (Ilbm->win);
Preview (Ilbm->win,Ilbm->win->Width,Ilbm->win->Height);
ResetMenuStrip (Ilbm->win,MAINMENU);
ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
RestoreCoords ();
}
break;
}
if (MyMenu & COORDS_MSG)
{
ModifyIDCMP (Ilbm->win,NULL);
ClearMenuStrip (Ilbm->win);
if (ShowCoords (Ilbm->win))
{
RealDist = fabs (RMAX-RMIN);
ImagDist = fabs (IMAX-IMIN);
Kre = RealDist / (double) (Ilbm->win->Width - 1);
Kim = ImagDist / (double) (Ilbm->win->Height - 1);
FracRatio = RealDist / ImagDist;
if (Choice (Ilbm->win,"Rendering requester","Recalculate ?")) MyMenu |= REDRAW_MSG;
}
ResetMenuStrip (Ilbm->win,MAINMENU);
ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
}
if (MyMenu & REDRAW_MSG)
{
if (ZMASK & MASK)
{
DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
MASK ^= ZMASK;
}
SetMenuStop (Ilbm->win);
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
ELAPSEDTIME = DrawFractal (Ilbm->win,(LONG) (Ilbm->win->LeftEdge),(LONG) (Ilbm->win->TopEdge),(LONG) (Ilbm->win->Width) - 1L,(LONG) (Ilbm->win->Height) - 1L);
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
SetMenuStart (Ilbm->win);
ShowTime (Ilbm->win,"Recalculate elapsed time:",ELAPSEDTIME);
break;
}
if (MyMenu & UNDO_MSG)
{
if (ZMASK & MASK)
{
DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
MASK ^= ZMASK;
}
RestoreCoords ();
RealDist = fabs (RMAX-RMIN);
ImagDist = fabs (IMAX-IMIN);
Kre = RealDist / (double) (Ilbm->win->Width - 1);
Kim = ImagDist / (double) (Ilbm->win->Height - 1);
FracRatio = RealDist / ImagDist;
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
SetMenuStop (Ilbm->win);
SetRast (Ilbm->wrp,BLACK);
ELAPSEDTIME = DrawFractal (Ilbm->win,(LONG) (Ilbm->win->LeftEdge),(LONG) (Ilbm->win->TopEdge),(LONG) (Ilbm->win->Width) - 1L,(LONG) (Ilbm->win->Height) - 1L);
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
SetMenuStart (Ilbm->win);
ShowTime (Ilbm->win,"Undo elapsed time:",ELAPSEDTIME);
break;
}
if (MyMenu & DRAW_MSG)
{
if (ZMASK & MASK)
{
DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
MASK ^= ZMASK;
}
if (NewCoords (Ilbm->win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4],ZOOMLINE [5]))
{
MYBITMAP = CopyBitMap (Ilbm->win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
PasteWin (MYBITMAP,Ilbm->win,ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
SetMenuStop (Ilbm->win);
PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
ELAPSEDTIME = DrawFractal (Ilbm->win,(LONG) (Ilbm->win->LeftEdge),(LONG) (Ilbm->win->TopEdge),(LONG) (Ilbm->win->Width) - 1L,(LONG) (Ilbm->win->Height) - 1L);
PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
SetMenuStart (Ilbm->win);
ShowTime (Ilbm->win,"Zoom elapsed time:",ELAPSEDTIME);
}
break;
}
break;
case IDCMP_RAWKEY: if (MyCode == RAW_ESC) MyMenu = EXIT_MSG;
break;
case IDCMP_CLOSEWINDOW: MyMenu = EXIT_MSG;
}
} while (! ((MyMenu & EXIT_MSG) || (MyMenu & NEWDISPLAY_MSG)));
if (ZMASK & MASK)
{
DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
MASK ^= ZMASK;
}
return MyMenu;
}
struct BitMap *CopyBitMap (struct Window *Win,WORD Left,WORD Top,WORD Width,WORD Height)
{
struct BitMap *NewBM;
NewBM = AllocBitMap (Width,Height,Win->RPort->BitMap->Depth,BMF_INTERLEAVED | BMF_CLEAR,NULL);
if (NewBM)
{
if (ZMASK & MASK) DrawBorder (Win->RPort,&MYBORDER,0,0);
if (TMASK & MASK) ShowTitle (Win->WScreen,FALSE);
BltBitMap (Win->RPort->BitMap,Left,Top,NewBM,0,0,Width,Height,0xC0,0xFF,NULL);
if (TMASK & MASK) ShowTitle (Win->WScreen,TRUE);
if (ZMASK & MASK) DrawBorder (Win->RPort,&MYBORDER,0,0);
MASK |= BMASK;
}
return NewBM;
}
BOOL PasteWin (struct BitMap *SrcBM,struct Window *DstWin,WORD SrcWidth,WORD SrcHeight)
{
BOOL Success = FALSE;
WORD DstWinWidth,DstWinHeight;
struct BitMap *TmpBM;
if (SrcBM)
{
DstWinWidth = ((DstWin->Flags & WFLG_GIMMEZEROZERO) ? DstWin->GZZWidth : DstWin->Width);
DstWinHeight = ((DstWin->Flags & WFLG_GIMMEZEROZERO) ? DstWin->GZZHeight : DstWin->Height);
TmpBM = AllocBitMap (DstWinWidth,DstWinHeight,DstWin->RPort->BitMap->Depth,BMF_INTERLEAVED | BMF_CLEAR,NULL);
if (TmpBM)
{
BSA.bsa_SrcWidth = SrcWidth;
BSA.bsa_SrcHeight = SrcHeight;
BSA.bsa_XSrcFactor = SrcWidth;
BSA.bsa_YSrcFactor = SrcHeight;
BSA.bsa_XDestFactor = DstWinWidth;
BSA.bsa_YDestFactor = DstWinHeight;
BSA.bsa_SrcBitMap = SrcBM;
BSA.bsa_DestBitMap = TmpBM;
BitMapScale (&BSA);
BltBitMapRastPort (TmpBM,0,0,DstWin->RPort,0,0,DstWinWidth,DstWinHeight,0xC0);
FreeBitMap (TmpBM);
Success = TRUE;
}
FreeBitMap (SrcBM);
MASK ^= BMASK;
}
return Success;
}
LONG WinDump (struct Window *Win)
{
struct IODRPReq *IODrp;
struct MsgPort *PrinterPort;
struct ViewPort *Vp;
LONG Error = PDERR_BADDIMENSION;
if (! Win) return Error;
if (PrinterPort = CreatePort (0,0))
{
if (IODrp = (struct IODRPReq *) CreateExtIO (PrinterPort,sizeof (struct IODRPReq)))
{
if (! (Error = OpenDevice ("printer.device",0,(struct IORequest *) IODrp,0)))
{
Vp = ViewPortAddress (Win);
IODrp->io_Command = PRD_DUMPRPORT;
IODrp->io_RastPort = Win->RPort;
IODrp->io_ColorMap = Vp->ColorMap;
IODrp->io_Modes = (ULONG) Vp->Modes;
IODrp->io_SrcX = Win->LeftEdge;
IODrp->io_SrcY = Win->TopEdge;
IODrp->io_SrcWidth = Win->Width;
IODrp->io_SrcHeight = Win->Height;
IODrp->io_DestCols = 0;
IODrp->io_Special = SPECIAL_FULLCOLS | SPECIAL_ASPECT;
Error = DoIO ((struct IORequest *)IODrp);
CloseDevice ((struct IORequest *)IODrp);
}
DeleteExtIO ((struct IORequest *)IODrp);
}
DeletePort (PrinterPort);
}
return Error;
}
ULONG Fail (UBYTE *ErrorString,ULONG ErrorLevel)
{
DisplayAlert (RECOVERY_ALERT,ErrorString,30);
RETURNVALUE = ErrorLevel;
return RETURNVALUE;
}
LONG main (ULONG Argc,UBYTE **Argv)
{
UWORD ModeIDMaxPlanes;
UBYTE **ToolTypes;
MYILBM.camg = DEF_MONITOR;
MYILBM.Bmhd.w = DEF_WIDTH;
MYILBM.Bmhd.h = DEF_HEIGHT;
MYILBM.Bmhd.nPlanes = DEF_PLANES;
if ((ToolTypes = ArgArrayInit (Argc,Argv)))
{
MYILBM.Bmhd.w = ArgInt (ToolTypes,"SCREENWIDTH",DEF_WIDTH);
MYILBM.Bmhd.h = ArgInt (ToolTypes,"SCREENHEIGHT",DEF_HEIGHT);
MYILBM.Bmhd.nPlanes = ArgInt (ToolTypes,"SCREENPLANES",DEF_PLANES);
sscanf (ArgString (ToolTypes,"SCREENMODE",DEF_MONITORSTR),"%lx",&MYILBM.camg);
sscanf (ArgString (ToolTypes,"REALMIN",INIT_DEF_RMINSTR),"%lf",&RMIN);
sscanf (ArgString (ToolTypes,"REALMAX",INIT_DEF_RMAXSTR),"%lf",&RMAX);
sscanf (ArgString (ToolTypes,"IMAGMIN",INIT_DEF_IMINSTR),"%lf",&IMIN);
sscanf (ArgString (ToolTypes,"IMAGMAX",INIT_DEF_IMAXSTR),"%lf",&IMAX);
ArgArrayDone ();
}
if (ModeNotAvailable (MYILBM.camg)) MYILBM.camg = ModeFallBack (MYILBM.camg,MYILBM.Bmhd.w,MYILBM.Bmhd.h,MYILBM.Bmhd.nPlanes);
ModeIDMaxPlanes = GetMaxPlanes (MYILBM.camg);
if (ModeIDMaxPlanes < 3)
{
Fail (OpenDisplayError,20L);
exit (RETURNVALUE);
}
MYILBM.Bmhd.w = MAX (MYILBM.Bmhd.w,DEF_WIDTH);
MYILBM.Bmhd.h = MAX (MYILBM.Bmhd.h,DEF_HEIGHT);
MYILBM.Bmhd.nPlanes = MAX (MYILBM.Bmhd.nPlanes,MIN_DEPTH);
if ((RMIN >= RMAX) || (IMIN >= IMAX))
{
DEF_RMIN = INIT_DEF_RMIN;
DEF_RMAX = INIT_DEF_RMAX;
DEF_IMIN = INIT_DEF_IMIN;
DEF_IMAX = INIT_DEF_IMAX;
}
else
{
DEF_RMIN = RMIN;
DEF_RMAX = RMAX;
DEF_IMIN = IMIN;
DEF_IMAX = IMAX;
}
SaveCoords ();
MYILBM.ParseInfo.propchks = IlbmProps;
MYILBM.ParseInfo.collectchks = IlbmCollects;
MYILBM.ParseInfo.stopchks = IlbmStops;
MYILBM.Bmhd.pageWidth = 0;
MYILBM.Bmhd.pageHeight = 0;
MYILBM.stype = CUSTOMSCREEN | SCREENQUIET;
MYILBM.TBState = TMASK & MASK;
MYILBM.ucliptype = OSCAN_TEXT;
MYILBM.EHB = TRUE;
MYILBM.Autoscroll = TRUE;
MYILBM.IFFPFlags = NULL;
FUNCTION = Integer;
PALETTE = COLORS_32_AGA;
H_LINE = HLine_S;
V_LINE = VLine_S;
if (MYILBM.Bmhd.nPlanes > ModeIDMaxPlanes) MYILBM.Bmhd.nPlanes = ModeIDMaxPlanes;
if (! CheckGFX ()) PALETTE = COLORS_32_ECS;
if (MAINMENU = CreateMenus (ProgMenu,TAG_END))
{
if (MYILBM.Bmhd.nPlanes < 6)
{
MAX_ITERATIONS = 63;
ItemAddress (MAINMENU,FULLMENUNUM (1,2,4))->Flags ^= CHECKED;
ItemAddress (MAINMENU,FULLMENUNUM (1,2,0))->Flags |= CHECKED;
}
if (CheckEHB (MYILBM.camg))
{
H_LINE = HLine_S_EHB;
V_LINE = VLine_S_EHB;
}
if (CheckFPU (SysBase->AttnFlags))
{
FUNCTION = Real;
ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags ^= CHECKED;
ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags |= CHECKED;
}
if (COLOR_PENS = MakeDisplay (&MYILBM))
{
COLOR_PENS -= 4L;
MANDChunk.LeftEdge = MYILBM.win->LeftEdge;
MANDChunk.TopEdge = MYILBM.win->TopEdge;
MANDChunk.Width = MYILBM.win->Width;
MANDChunk.Height = MYILBM.win->Height;
MANDChunk.RMin = RMIN;
MANDChunk.RMax = RMAX;
MANDChunk.IMin = IMIN;
MANDChunk.IMax = IMAX;
MANDChunk.Iterations = MAX_ITERATIONS + 1L;
MANDChunk.Special = NULL;
SPECIAL_CHUNK.ch_Data = &MANDChunk;
PutPointer (MYILBM.win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
ELAPSEDTIME = DrawFractal (MYILBM.win,(LONG) (MYILBM.win->LeftEdge),(LONG) (MYILBM.win->TopEdge),(LONG) (MYILBM.win->Width) - 1L,(LONG) (MYILBM.win->Height) - 1L);
PutPointer (MYILBM.win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
SetMenuStart (MYILBM.win);
ShowTime (MYILBM.win,"Rendering elapsed time:",ELAPSEDTIME);
ModifyIDCMP (MYILBM.win,NULL);
ClearMenuStrip (MYILBM.win);
About (MYILBM.win);
ResetMenuStrip (MYILBM.win,MAINMENU);
ModifyIDCMP (MYILBM.win,IDCMP_STANDARD);
do
{
while (HandleEvents (&MYILBM) & NEWDISPLAY_MSG)
{
if (SMRequest (&MYILBM))
{
MYBITMAP = CopyBitMap (MYILBM.win,MYILBM.win->LeftEdge,MYILBM.win->TopEdge,MYILBM.win->Width,MYILBM.win->Height);
CloseDisplay (&MYILBM,VINFO);
MYILBM.Bmhd.pageWidth = 0;
MYILBM.Bmhd.pageHeight = 0;
COLOR_PENS = MakeDisplay (&MYILBM);
if (COLOR_PENS)
{
COLOR_PENS -= 4L;
PasteWin (MYBITMAP,MYILBM.win,GetBitMapAttr (MYBITMAP,BMA_WIDTH),GetBitMapAttr (MYBITMAP,BMA_HEIGHT));
if (CheckEHB (MYILBM.camg))
{
if (SPREAD == FALSE)
{
H_LINE = HLine_R_EHB;
V_LINE = VLine_R_EHB;
}
else
{
H_LINE = HLine_S_EHB;
V_LINE = VLine_S_EHB;
}
}
else
{
if (SPREAD == FALSE)
{
H_LINE = HLine_R;
V_LINE = VLine_R;
}
else
{
H_LINE = HLine_S;
V_LINE = VLine_S;
}
}
if (Choice (MYILBM.win,"Rendering requester","Recalculate ?"))
{
SetMenuStop (MYILBM.win);
PutPointer (MYILBM.win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
ELAPSEDTIME = DrawFractal (MYILBM.win,(LONG) (MYILBM.win->LeftEdge),(LONG) (MYILBM.win->TopEdge),(LONG) (MYILBM.win->Width) - 1L,(LONG) (MYILBM.win->Height) - 1L);
PutPointer (MYILBM.win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
SetMenuStart (MYILBM.win);
ShowTime (MYILBM.win,"Rendering elapsed time:",ELAPSEDTIME);
}
}
else
{
Fail (MakeDisplayError,20L);
break;
}
}
}
if (RETURNVALUE >= 20L) break;
} while (! Choice (MYILBM.win,"Exit requester","Are you sure ?"));
if (BMASK & MASK) FreeBitMap (MYBITMAP);
}
else Fail (MakeDisplayError,20L);
CloseDisplay (&MYILBM,VINFO);
FreeMenus (MAINMENU);
}
else Fail (MenuError,20L);
exit (RETURNVALUE);
}